Method: Spec::Rails::Example::FunctionalExampleGroup#cookies
- Defined in:
- lib/spec/rails/example/functional_example_group.rb
#cookies ⇒ Object
Overrides the cookies() method in ActionController::TestResponseBehaviour, returning a proxy that accesses the requests cookies when setting a cookie and the responses cookies when reading one. This allows you to set and read cookies in examples using the same API with which you set and read them in controllers.
Examples (Rails 2.0 > 2.2)
[:user_id] = {:value => '1234', :expires => 1.minute.ago}
get :index
response.should be_redirect
Examples (Rails 2.3)
Rails 2.3 changes the way cookies are made available to functional tests (and therefore rspec controller specs), only making single values available with no access to other aspects of the cookie. This is backwards-incompatible, so you have to change your examples to look like this:
[:foo] = 'bar'
get :index
[:foo].should == 'bar'
71 72 73 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 71 def ||= Spec::Rails::Example::CookiesProxy.new(self) end |