Module: RSpec::Rails::ControllerExampleGroup
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActionController::TestCase::Behavior, AssertionDelegator.new( ActionDispatch::Assertions::RoutingAssertions ), Matchers::RedirectTo, Matchers::RenderTemplate, Matchers::RoutingMatchers, RailsExampleGroup, ViewRendering
- Defined in:
- lib/rspec/rails/example/controller_example_group.rb
Overview
Container module for controller spec functionality.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the controller object instance under test.
-
#routes ⇒ Object
readonly
Returns the Rails routes used for the spec.
Instance Method Summary collapse
-
#bypass_rescue ⇒ Object
Extends the controller with a module that overrides
rescue_with_handler
to raise the exception passed to it. -
#method_missing(method, *args, &block) ⇒ Object
If method is a named_route, delegates to the RouteSet associated with this controller.
Methods included from Matchers::RoutingMatchers
Methods included from Matchers::RenderTemplate
Methods included from Matchers::RedirectTo
Methods included from ViewRendering
Methods included from Matchers
#be_a_new, #be_new_record, #be_valid, #have_been_enqueued, #have_enqueued_job, #have_http_status
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
If method is a named_route, delegates to the RouteSet associated with this controller.
172 173 174 175 176 177 178 |
# File 'lib/rspec/rails/example/controller_example_group.rb', line 172 def method_missing(method, *args, &block) if route_available?(method) controller.send(method, *args, &block) else super end end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the controller object instance under test.
128 129 130 |
# File 'lib/rspec/rails/example/controller_example_group.rb', line 128 def controller @controller end |
#routes ⇒ Object
Returns the Rails routes used for the spec.
132 133 134 |
# File 'lib/rspec/rails/example/controller_example_group.rb', line 132 def routes @routes end |
Instance Method Details
#bypass_rescue ⇒ Object
Extends the controller with a module that overrides
rescue_with_handler
to raise the exception passed to it. Use this to
specify that an action should raise an exception given appropriate
conditions.
166 167 168 |
# File 'lib/rspec/rails/example/controller_example_group.rb', line 166 def bypass_rescue controller.extend(BypassRescue) end |