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

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

Assert that the redirection options passed in match those of the redirect called in the latest action.

#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(sym, *args, &block)

Delegate unhandled messages to the current session instance.

[ GitHub ]

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

def method_missing(sym, *args, &block)
  reset! unless integration_session
  if integration_session.respond_to?(sym)
    integration_session.__send__(sym, *args, &block).tap do
      copy_session_variables!
    end
  else
    super
  end
end

Instance Attribute Details

#default_url_options (rw)

[ GitHub ]

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

def default_url_options
  reset! unless integration_session
  integration_session.default_url_options
end

#default_url_options=(options) (rw)

[ GitHub ]

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

def default_url_options=(options)
  reset! unless integration_session
  integration_session.default_url_options = options
end

Instance Method Details

#app

[ GitHub ]

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

def app
  @app ||= nil
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 362

def open_session
  dup.tap do |session|
    session.reset!
    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 326

def reset!
  @integration_session = Integration::Session.new(app)
end

#respond_to?(method, include_private = false) ⇒ Boolean

[ GitHub ]

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

def respond_to?(method, include_private = false)
  integration_session.respond_to?(method, include_private) || super
end