10

如何在我的请求规范中设置 cookie?

以下页面上的解决方案不起作用:

Rspec:在辅助测试中设置 cookie

即,request.cookies[:whatever] = 'something'说那request是一个nil对象。我也试过helper.cookies[:whatever] = 'something'了,那也没有用(helper在那种情况下nil)。

4

2 回答 2

5

请尝试以下操作:

cookies[:whatever] = 'something'
于 2014-05-12T04:38:46.113 回答
-2

Make sure you are using the rspec-rails gem and are requiring 'rspec/rails' in your spec_helper, not just 'rspec'.

于 2012-12-13T19:22:06.787 回答