[rspec-users] Cookie assignment and reading

Josh Clayton joshua.clayton at gmail.com
Tue Jun 29 17:05:50 EDT 2010

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

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

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!

More information about the rspec-users mailing list