![](/img/trans.png)
[英]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.