Eri*_*ang 4 cookies rspec ruby-on-rails capybara
我正在尝试在我的请求规范中测试cookie:
require 'spec_helper'
describe "Cookies"
it "should set correctly" do
request.cookies['foo'] = 'bar'
end
end
Run Code Online (Sandbox Code Playgroud)
但这给了我undefined method 'cookies' for nil:NilClass.我该如何解决?
该request对象将是你的测试用例中零,直到您使用的方法之一的HTTP请求get,post,delete,put,等.
例如,如果您之前request.cookies['foo'] = 'bar'有代码,则代码将起作用get root_path.
| 归档时间: |
|
| 查看次数: |
2256 次 |
| 最近记录: |