| Class | Spec::Rails::Example::FunctionalExampleGroup |
| In: |
lib/spec/rails/example/functional_example_group.rb
|
| Parent: | ActionController::TestCase |
| assigns | -> | orig_assigns |
| 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
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] = {:value => '1234', :expires => 1.minute.ago}
get :index
response.should be_redirect
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:
cookies[:foo] = 'bar' get :index cookies[:foo].should == 'bar'
Provides access to the flash hash. Use this after rendering a view, calling a helper or calling a controller action.
post :create flash[:notice].should == "Success!"
The params hash accessed within a view or helper. Use this before rendering a view or calling a helper to provide data used by the view or helper.
# in a view spec
params[:name] = "David"
render
response.should have_tag("div.name","David")
# in a helper spec
params[:first_name] = "David"
params[:last_name] = "Chelimsky"
helper.full_name.should == "David Chelimsky"
Provides access to the session hash. Use this before or after rendering a view, calling a helper or calling a controller action.