[英]Rails + Cucumber/Capybara: How to set/retrieve cookies in tests?
[英]Rails capybara cookies issue
如何在水豚内使用Cookie?
在我的application_helper.rb
我有使用cookies
方法
def user_currency(currency)
cookies[:user_currency] = currency
end
但是当我想在测试中使用这种方法时
它返回我
undefined local variable or method `cookies' for #<RSpec::ExampleGroups
如何处理?
每个Capybara驱动程序的Cookie操作都不同。 最简单的解决方案是使用show_me_the_cookies gem,它提供了统一的API。 请注意,对于某些驱动程序,您只能为当前访问的域设置Cookie。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.