Reputation: 505
I've got file /rspec/support/utilities.rb with method:
def sign_in(user)
remember_token = User.new_token
cookies.signed["remember_token"] = remember_token
user.update_attribute(:remember_token, User.encrypt(remember_token))
end
But when I run tests, I get this error:
undefined method `signed' for Rack::Test::CookieJar
So, I guess there is no methods like "signed" and "permanent" in this class, but how can I make tests for cookies then?
Upvotes: 1
Views: 1232
Reputation: 49850
You have this question tagged with Capybara, so I'm not really sure whether you're attempting to do controller tests (wouldn't use Capybara) or integration tests (would use capybara). If you are doing integrations tests using Capybara, you can't set cookies like that. You would need to go to the login page, click the remember me checkbox and login, then you could use the show_me_the_cookies gem (https://github.com/nruth/show_me_the_cookies), which provides a consistent cookies API across multiple Capybara drivers, to check the cookies saved in the browser
Upvotes: 1