Class/Module Index [+]

Quicksearch

ActionController::Integration::Runner

Public Class Methods

new(*args) click to toggle source
# File lib/action_controller/integration.rb, line 498
def initialize(*args)
  super
  @integration_session = nil
end

Public Instance Methods

method_missing(sym, *args, &block) click to toggle source

Delegate unhandled messages to the current session instance.

# File lib/action_controller/integration.rb, line 568
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
open_session(application = nil) click to toggle source

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 lib/action_controller/integration.rb, line 531
def open_session(application = nil)
  session = Integration::Session.new(application)

  # delegate the fixture accessors back to the test instance
  extras = Module.new { attr_accessor :delegate, :test_result }
  if self.class.respond_to?(:fixture_table_names)
    self.class.fixture_table_names.each do |table_name|
      name = table_name.tr(".", "_")
      next unless respond_to?(name, true)
      extras.__send__(:define_method, name) { |*args|
        delegate.send(name, *args)
      }
    end
  end

  # delegate add_assertion to the test case
  extras.__send__(:define_method, :add_assertion) {
    test_result.add_assertion
  }
  session.extend(extras)
  session.delegate = self
  session.test_result = @_result

  yield session if block_given?
  session
end
reset!() click to toggle source

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

# File lib/action_controller/integration.rb, line 505
def reset!
  @integration_session = open_session
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.