123456789_123456789_123456789_123456789_123456789_

Module: ActionDispatch::Integration::Runner

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: actionpack/lib/action_dispatch/testing/integration.rb

Constant Summary

Instance Attribute Summary

Instance Method Summary

::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 path was handled correctly and that the parsed options (given in the expected_options hash) match path.

#assert_routing

Asserts that path and options match both ways; in other words, it verifies that path generates options and then that options generates path.

#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.

::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:

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) (private)

Delegate unhandled messages to the current session instance.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 427

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

Instance Attribute Details

#app (readonly)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 321

attr_reader :app

#default_url_options (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 413

def default_url_options
  integration_session.default_url_options
end

#default_url_options=(options) (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 417

def default_url_options=(options)
  integration_session.default_url_options = options
end

Instance Method Details

#create_session(app)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 344

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 324

def initialize(*args, &blk)
  super(*args, &blk)
  @integration_session = nil
end

#integration_session

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 334

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.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 389

def open_session
  dup.tap do |session|
    session.reset!
    session.root_session = self.root_session || self
    yield session if block_given?
  end
end

#reset!

Reset the current session. This is useful for testing multiple sessions in a single test case.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 340

def reset!
  @integration_session = create_session(app)
end