Class | Spec::Rails::Example::FunctionalExampleGroup |
In: |
vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb
|
Parent: | Spec::Rails::Example::RailsExampleGroup |
request | [R] | |
response | [R] |
Hash of instance variables to values that are made available to views. == Examples
#in thing_controller.rb def new @thing = Thing.new end #in thing_controller_spec get 'new' assigns[:registration].should == Thing.new
# File vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb, line 74 74: def assigns(key = nil) 75: if key.nil? 76: _assigns_hash_proxy 77: else 78: _assigns_hash_proxy[key] 79: end 80: end
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.
cookies[:user_id] = '1234' get :index assigns[:user].id.should == '1234' post :login cookies[:login].expires.should == 1.week.from_now
cookies[:user_id] = {:value => '1234', :expires => 1.minute.ago} get :index response.should be_redirect
# File vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb, line 52 52: def cookies 53: @cookies ||= Spec::Rails::Example::CookiesProxy.new(self) 54: end
# File vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb, line 23 23: def flash 24: response.flash 25: end