[rspec-users] Cookies - how to set in controller specs?

Craig Demyanovich cdemyanovich at gmail.com
Wed Jul 2 14:44:01 EDT 2008


> I'm thinking of replacing the existing cookies() method (in the example)
> with one that returns a CookieJarProxy that will allow you to do any of the
> following:
>
> cookies['cookie_key'] = 'cookie value'
> cookies[:cookie_key] = 'cookie value'
>
> cookies['cookie_key'].should == 'cookie value'
> cookies[:cookie_key].should == 'cookie value'
>
> WDYT about that?

David, do you plan to allow checks that other values are set as we'd
expect? Other values include:

* :value
* :path
* :domain
* :expires
* :secure
* :http_only

http://www.railsbrain.com/api/rails-2.1.0/doc/index.html?a=M000352&name=cookies

For example, I'd like to verify that I update the value and expiration date:

it "resets the cookie with the value and new expiration date" do
  get_index
  cookies[:project_sort][:value].should == "name"
  cookies[:project_sort][:expires].beginning_of_day.should ==
1.year.from_now.beginning_of_day
end

Thanks,
Craig


More information about the rspec-users mailing list