As part of my integration tests for a website I am using cucumber with capybara. It seems that capybara cannot emulate the use of cookies.
For example I set the cookie when the user signs in:
def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.salt]
current_user = user
end
However when I later fetch the value of cookies using cookies.inspect it returns {}
Is this a known limiting of capybara? How can I test a signed in user over multiple requests if this is the case?
I should add my test:
Scenario: User is signed in when they press Sign In
Given I have an existing account with email "bob@jones.com" and password "123456"
And I am on the signin page
When I fill in "Email" with "bob@jones.com"
And I fill in "Password" with "123456"
And I press "Sign In"
Then I should see "Welcome Bob Jones"
Best Answer
Here's a step that works for me. It sets a cookie "admin_cta_choice" to be equal to a model id derived from the input value.