class Spec::Rails::Example::FunctionalExampleGroup
def assigns(key = nil)
assigns(:key) for backwards compatibility.
NOTE - Even though docs only use assigns[:key] format, this supports
--
assigns[:registration].should == Thing.new
get 'new'
#in thing_controller_spec
end
@thing = Thing.new
def new
#in thing_controller.rb
views. == Examples
Hash of instance variables to values that are made available to
assigns()
:call-seq:
def assigns(key = nil) if key.nil? _assigns_hash_proxy else _assigns_hash_proxy[key] end end
def cookies
get :index
cookies[:foo] = 'bar'
look like this:
is backwards-incompatible, so you have to change your examples to
values available with no access to other aspects of the cookie. This
tests (and therefore rspec controller specs), only making single
Rails 2.3 changes the way cookies are made available to functional
== Examples (Rails 2.3)
response.should be_redirect
get :index
cookies[:user_id] = {:value => '1234', :expires => 1.minute.ago}
== Examples (Rails 2.0 > 2.2)
them in controllers.
cookies in examples using the same API with which you set and read
responses cookies when reading one. This allows you to set and read
accesses the requests cookies when setting a cookie and the
ActionController::TestResponseBehaviour, returning a proxy that
Overrides the cookies() method in
def cookies @cookies ||= Spec::Rails::Example::CookiesProxy.new(self) end
def flash
post :create
== Examples
view, calling a helper or calling a controller action.
Provides access to the flash hash. Use this after rendering a
def flash @controller.__send__ :flash end
def params
params[:last_name] = "Chelimsky"
params[:first_name] = "David"
# in a helper spec
response.should have_tag("div.name","David")
render
params[:name] = "David"
# in a view spec
== Examples
view or helper.
rendering a view or calling a helper to provide data used by the
The params hash accessed within a view or helper. Use this before
def params request.parameters end
def session
Provides acces to the session hash. Use this before or after
def session request.session end
def setup
def setup # no-op to override AC::TC's setup w/ conflicts with the before(:each) below end