-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Ruby version: 2.6.5p114
Rails version: 5.2.3
RSpec version: 3.8
When testing a controller that deletes a cookie.
The cookie is removed from the response but not the cookies object.
Is this possibly something we are doing wrong in our app?
pry in test after subject is called
[3] pry(#<RSpec::Matchers::DSL::Matcher>)> cookies
=> #<ActionDispatch::Cookies::CookieJar:0x00007ff11de14478
@committed=false,
@cookies={"foo"=>"encrypted_string"},
@delete_cookies={},
@request= <...omitted...>
[4] pry(#<RSpec::Matchers::DSL::Matcher>)> response.cookies
=> {"foo"=>nil}
Expected behaviour
cookies == request.cookies
Can you provide an example app?
class FoosController < ApplicationController
def show
cookies.delete(:foo)
render plain: "foo"
end
end
describe FooController do
describe "#show" do
subject { -> { get :show } }
context "when a foo cookie is present" do
before { cookies[:foo] = "encrypted_string" }
it { subject.call; expect(response.cookies[:foo]).to eq(nil) } #passes
it { subject.call; expect(cookies[:foo]).to eq(nil) } #fails
end
end
end
Metadata
Metadata
Assignees
Labels
No labels