module ActionDispatch::Integration::Runner
def assertions # :nodoc:
def assertions # :nodoc: root_session ? root_session.assertions : super end
def assertions=(assertions) # :nodoc:
def assertions=(assertions) # :nodoc: root_session ? root_session.assertions = assertions : super end
def before_setup # :nodoc:
def before_setup # :nodoc: @app = nil super end
def copy_session_variables! # :nodoc:
test instance.
Copy the instance variables from the current session instance into the
def copy_session_variables! # :nodoc: @controller = @integration_session.controller @response = @integration_session.response @request = @integration_session.request end
def create_session(app)
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
def default_url_options
def default_url_options integration_session.default_url_options end
def default_url_options=(options)
def default_url_options=(options) integration_session.default_url_options = options end
def initialize(*args, &blk)
def initialize(*args, &blk) super(*args, &blk) @integration_session = nil end
def integration_session
def integration_session @integration_session ||= create_session(app) end
def method_missing(method, *args, &block)
def method_missing(method, *args, &block) if integration_session.respond_to?(method) integration_session.public_send(method, *args, &block).tap do copy_session_variables! end else super end end
def open_session
can use this method to open multiple sessions that ought to be tested
By default, a single session is automatically created for you, but you
end
sess.extend(CustomAssertions)
session = open_session do |sess|
yielded to the block before being returned.
Open a new session instance. If a block is given, the new session is
def open_session dup.tap do |session| session.reset! session.root_session = self.root_session || self yield session if block_given? end end
def remove! # :nodoc:
def remove! # :nodoc: @integration_session = nil end
def reset!
Reset the current session. This is useful for testing multiple sessions
def reset! @integration_session = create_session(app) end
def respond_to_missing?(method, _)
def respond_to_missing?(method, _) integration_session.respond_to?(method) || super end