Class: Spec::Rails::Example::FunctionalExampleGroup
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- Spec::Rails::Example::FunctionalExampleGroup
- Defined in:
- lib/spec/rails/example/functional_example_group.rb
Direct Known Subclasses
ControllerExampleGroup, HelperExampleGroup, ViewExampleGroup
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#assigns(key = nil) ⇒ Object
:call-seq: assigns().
-
#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. - #flash ⇒ Object
- #orig_assigns ⇒ Object
- #params ⇒ Object
- #session ⇒ Object
- #setup ⇒ Object
Methods inherited from ActionController::TestCase
Methods included from RoutingHelpers
Methods included from RoutingHelpers::ParamsFromQueryString
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
11 12 13 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 11 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 11 def response @response end |
Instance Method Details
#assigns(key = nil) ⇒ Object
:call-seq:
assigns()
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
– NOTE - Even though docs only use assigns format, this supports assigns(:key) for backwards compatibility. ++
73 74 75 76 77 78 79 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 73 def assigns(key = nil) if key.nil? _assigns_hash_proxy else _assigns_hash_proxy[key] end end |
#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'
49 50 51 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 49 def @cookies ||= Spec::Rails::Example::CookiesProxy.new(self) end |
#flash ⇒ Object
17 18 19 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 17 def flash @controller.__send__ :flash end |
#orig_assigns ⇒ Object
53 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 53 alias_method :orig_assigns, :assigns |
#params ⇒ Object
13 14 15 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 13 def params request.parameters end |
#session ⇒ Object
21 22 23 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 21 def session request.session end |
#setup ⇒ Object
7 8 9 |
# File 'lib/spec/rails/example/functional_example_group.rb', line 7 def setup # no-op to override AC::TC's setup w/ conflicts with the before(:each) below end |