Reputation: 3945
I am testing an app that would be installed on a sub domain to take advantage of the cookies created by the main app. How ever unless both apps are running on, say: site.local.com
the app I am testing doesn't have access to a session controller, thus I cannot create cookies in testing via typical sign in methods.
So my question is, how do I - in capybara - fake cookies? I have tried something like:
it "should ... ", type: :request do
sign_in(@user)
...
end
#sign_in definition:
def sign_in(user)
cookies.signed[:auth_token] = user.auth_token
end
How ever the issue is:
Failure/Error: sign_in(@user)
NameError:
undefined local variable or method `cookies' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x000000090cd998>
Upvotes: 1
Views: 1062
Reputation: 13181
Try this:
page.driver.browser.set_cookie("auth_token=#{user.auth_token}")
Upvotes: 4