Module: ActionDispatch::Integration::Runner
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::ActionDispatch::Assertions ,
Rails::Dom::Testing::Assertions,
::ActionDispatch::Assertions::RoutingAssertions ,
::ActionDispatch::Assertions::ResponseAssertions
|
|
Defined in: | actionpack/lib/action_dispatch/testing/integration.rb |
Constant Summary
-
APP_SESSIONS =
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 337{}
::ActionDispatch::Assertions::ResponseAssertions
- Included
Instance Attribute Summary
- #app readonly
- #default_url_options rw
- #default_url_options=(options) rw
- #assertions rw Internal use only
- #assertions=(assertions) rw Internal use only
- #root_session rw Internal use only
Instance Method Summary
- #create_session(app)
- #initialize(*args, &blk)
- #integration_session
-
#open_session
Open a new session instance.
-
#reset!
Reset the current session.
-
#method_missing(method)
private
Delegate unhandled messages to the current session instance.
- #respond_to_missing?(method, _) ⇒ Boolean private
- #before_setup Internal use only
-
#copy_session_variables!
Internal use only
Copy the instance variables from the current session instance into the test instance.
- #remove! Internal use only
::ActionDispatch::Assertions
- Included
::ActionDispatch::Assertions::RoutingAssertions
- Included
#assert_generates | Asserts that the provided options can be used to generate the provided path. |
#assert_recognizes | Asserts that the routing of the given |
#assert_routing | Asserts that path and options match both ways; in other words, it verifies that |
#method_missing | ROUTES TODO: These assertions should really work in an integration context. |
#with_routing | A helper to make it easier to test different route configurations. |
#create_routes, #fail_on, | |
#recognized_request_for | Recognizes the route for a given path. |
#reset_routes, #setup |
::ActionDispatch::Assertions::ResponseAssertions
- Included
#assert_redirected_to | Asserts that the response is a redirect to a URL matching the given options. |
#assert_response | Asserts that the response is one of the following types: |
#code_with_name, #exception_if_present, #generate_response_message, #location_if_redirected, #normalize_argument_to_redirection, | |
#parameterize | Proxy to to_param if the object will respond to it. |
#response_body_if_short |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) (private)
Delegate unhandled messages to the current session instance.
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 442
def method_missing(method, ...) if integration_session.respond_to?(method) integration_session.public_send(method, ...).tap do copy_session_variables! end else super end end
Instance Attribute Details
#app (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 339
attr_reader :app
#assertions (rw)
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 412
def assertions # :nodoc: root_session ? root_session.assertions : super end
#assertions=(assertions) (rw)
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 416
def assertions=(assertions) # :nodoc: root_session ? root_session.assertions = assertions : super end
#default_url_options (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 428
def integration_session. end
#default_url_options=(options) (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 432
def ( ) integration_session. = end
#root_session (rw)
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 340
attr_accessor :root_session # :nodoc:
Instance Method Details
#before_setup
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 347
def before_setup # :nodoc: @app = nil super end
#copy_session_variables!
Copy the instance variables from the current session instance into the test instance.
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 422
def copy_session_variables! # :nodoc: @controller = @integration_session.controller @response = @integration_session.response @request = @integration_session.request end
#create_session(app)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 362
def create_session(app) klass = APP_SESSIONS[app] ||= Class.new(Integration::Session) { # If the app is a Rails app, make url_helpers available on the session. This # makes app.url_for and app.foo_path available in the console. if app.respond_to?(:routes) && app.routes.is_a?(ActionDispatch::Routing::RouteSet) include app.routes.url_helpers include app.routes.mounted_helpers end } klass.new(app) end
#initialize(*args, &blk)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 342
def initialize(*args, &blk) super(*args, &blk) @integration_session = nil end
#integration_session
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 352
def integration_session @integration_session ||= create_session(app) end
#open_session
Open a new session instance. If a block is given, the new session is yielded to the block before being returned.
session = open_session do |sess|
sess.extend(CustomAssertions)
end
By default, a single session is automatically created for you, but you can use this method to open multiple sessions that ought to be tested simultaneously.
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 404
def open_session dup.tap do |session| session.reset! session.root_session = self.root_session || self yield session if block_given? end end
#remove!
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 374
def remove! # :nodoc: @integration_session = nil end
#reset!
Reset the current session. This is useful for testing multiple sessions in a single test case.
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 358
def reset! @integration_session = create_session(app) end
#respond_to_missing?(method, _) ⇒ Boolean
(private)
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 437
def respond_to_missing?(method, _) integration_session.respond_to?(method) || super end