Cookie assignment and reading

Hello all,

I’m running the latest stable rspec/rspec-rails (1.3.0/1.3.2) in a
Rails 2.3.8 app and am having trouble testing that a cookie gets
deleted.

In a semi-convoluted manner, I am essentially running code from the
rdoc as such:

describe MyController, "GET index" do
  let(:cookie_value) { "of course" }

  it "should delete the cookie" do
    cookies[:awesome] = cookie_value
    get :index
    cookies[:awesome].should == cookie_value
  end
end

This is obviously example code but the outcome effect is the same -
trying to find the value of a cookie I set with RSpec fails. For my
specific, real-life example, I’m assigning a cooking and performing a
request in the before block and testing that the cookie is deleted.
It’s passing, but incorrectly (since I haven’t performed the deletion
in my controller action).

Any insight would be appreciated; thanks!

On Jun 29, 2010, at 4:05 PM, Josh Clayton wrote:

 let(:cookie_value) { "of course" }

specific, real-life example, I’m assigning a cooking and performing a
request in the before block and testing that the cookie is deleted.
It’s passing, but incorrectly (since I haven’t performed the deletion
in my controller action).

Any insight would be appreciated; thanks!

That should work. Please file a bug: http://rspec.lighthouseapp.com/

Thx,
David

David,

Thanks; I thought I was going crazy! The ticket is here:
https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/1023-cookie-assignment-and-reading-doesnt-work-if-both-occur-in-the-same-spec

Thanks again!