简体   繁体   中英

Rails capybara cookies issue

How to work with cookies inside capybara?

in my application_helper.rb i have method with cookies

def user_currency(currency)
 cookies[:user_currency] = currency
end

but when i want to use this method in my test

it returns me

undefined local variable or method `cookies' for #<RSpec::ExampleGroups

How to handle it?

Cookie manipulation is different for each Capybara driver. The easiest solution is to use the show_me_the_cookies gem which provides a unified API. Note that with some drivers you can only set cookies for domains you are currently visiting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM