Module: RSpec::Rails::ControllerExampleGroup
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ViewRendering::ClassMethods ,
MinitestAssertionAdapter::ClassMethods ,
SetupAndTeardownAdapter::ClassMethods ,
ActiveSupport::Concern
|
|
Instance Chain:
self,
RSpec::Rails::AssertionDelegator.new(
ActionDispatch::Assertions::RoutingAssertions
),
Matchers::RoutingMatchers ,
Matchers::RenderTemplate ,
Matchers::RedirectTo ,
ViewRendering ,
ActionController::TestCase::Behavior,
RailsExampleGroup ,
ActiveSupport::ExecutionContext::TestHelper,
ActiveSupport::CurrentAttributes::TestHelper,
TaggedLoggingAdapter ,
FixtureSupport::Fixtures ,
FixtureSupport ,
ActiveRecord::TestFixtures,
MinitestAssertionAdapter ,
MinitestLifecycleAdapter ,
SetupAndTeardownAdapter
|
|
Defined in: | rspec-rails/lib/rspec/rails/example/controller_example_group.rb |
Overview
Container module for controller spec functionality.
Constant Summary
ViewRendering
- Included
Class Attribute Summary
ViewRendering::ClassMethods
- Extended
Class Method Summary
ViewRendering::ClassMethods
- Extended
MinitestAssertionAdapter::ClassMethods
- Extended
assertion_method_names | Returns the names of assertion methods that we want to expose to examples without exposing non-assertion methods in Test::Unit or Minitest. |
define_assertion_delegators |
SetupAndTeardownAdapter::ClassMethods
- Extended
Instance Attribute Summary
-
#controller
readonly
Returns the controller object instance under test.
-
#routes
rw
Returns the
::RSpec::Rails
routes used for the spec. -
#routes=(routes)
rw
Internal use only
Internal use only
::RSpec
Rails uses this to make::RSpec::Rails
routes easily available to specs.
ViewRendering
- Included
#controller | Returns the controller object instance under test. |
#render_views?, #controller= |
FixtureSupport
- Included
#run_in_transaction? | Monkey patched to avoid collisions with ‘let(:name)’ since |
Instance Method Summary
-
#bypass_rescue
Extends the controller with a module that overrides
rescue_with_handler
to raise the exception passed to it. -
#method_missing(method, *args, &block)
If method is a named_route, delegates to the RouteSet associated with this controller.
- #route_available?(method) ⇒ Boolean private
- #route_defined?(routes, method) ⇒ Boolean private
Matchers::RoutingMatchers
- Included
#be_routable | Passes if the route expression is recognized by the |
#route_to | Delegates to |
Matchers::RenderTemplate
- Included
#have_rendered | Delegates to |
#render_template | Alias for Matchers::RenderTemplate#have_rendered. |
Matchers::RedirectTo
- Included
#redirect_to | Delegates to |
TaggedLoggingAdapter
- Included
#tagged_logger | Vendored from activesupport/lib/active_support/testing/tagged_logging.rb This implements the tagged_logger method where it is expected, but doesn’t call |
MinitestAssertionAdapter
- Included
MinitestLifecycleAdapter
- Included
SetupAndTeardownAdapter
- Included
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block)
If method is a named_route, delegates to the RouteSet associated with this controller.
# File 'rspec-rails/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
DSL Calls
included
[ GitHub ]181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
# File 'rspec-rails/lib/rspec/rails/example/controller_example_group.rb', line 181
included do subject { controller } before do self.routes = ::Rails.application.routes end around do |ex| previous_allow_forgery_protection_value = ActionController::Base.allow_forgery_protection begin ActionController::Base.allow_forgery_protection = false ex.call ensure ActionController::Base.allow_forgery_protection = previous_allow_forgery_protection_value end end end
Instance Attribute Details
#controller (readonly)
Returns the controller object instance under test.
# File 'rspec-rails/lib/rspec/rails/example/controller_example_group.rb', line 128
attr_reader :controller
#routes (rw)
Returns the ::RSpec::Rails
routes used for the spec.
# File 'rspec-rails/lib/rspec/rails/example/controller_example_group.rb', line 132
attr_reader :routes
#routes=(routes) (rw)
::RSpec
Rails uses this to make ::RSpec::Rails
routes easily available to specs.
Instance Method Details
#bypass_rescue
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.
# File 'rspec-rails/lib/rspec/rails/example/controller_example_group.rb', line 166
def bypass_rescue controller.extend(BypassRescue) end
#route_available?(method) ⇒ Boolean
(private)
# File 'rspec-rails/lib/rspec/rails/example/controller_example_group.rb', line 201
def route_available?(method) (defined?(@routes) && route_defined?(routes, method)) || (defined?(@orig_routes) && route_defined?(@orig_routes, method)) end