I'm trying to pass a cookie when doing a GET request, using rspec 2 and rails 3.
I've tried the following so far.
get "/", {}, {"Cookie" => "uuid=10"} # cookies[:uuid] is nil
request.cookies[:uuid] = 10 # request is nil
@request.env["Cookie"] = "uuid=10" # @request is nil
helper.request.cookies[:uuid] # helper is not defined
cookies[:uuid] = 10 # cookies[:uuid] is nil
controller.cookies[:uuid] = 10 # cookies is nil
Is it possible?
Per this answer, you can use the cookies
method within request specs:
before { cookies['foo'] = 'bar' }
I tried @phoet's solution involving ActionDispatch::Request.any_instance.stubs
, but it throws an error along with a seemingly unrelated deprecation message in RSpec 3.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With