Module: ActionDispatch::Integration::Runner

Includes:
Assertions
Included in:
ActionDispatch::IntegrationTest
Defined in:
actionpack/lib/action_dispatch/testing/integration.rb

Constant Summary

Constants included from Assertions

Assertions::NO_STRIP

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

#append_features, extended, #included

Methods included from Assertions::TagAssertions

#assert_no_tag, #assert_tag, #find_all_tag, #find_tag, #html_document

Methods included from Assertions::SelectorAssertions

#assert_select, #assert_select_email, #assert_select_encoded, #count_description, #css_select

Methods included from Assertions::RoutingAssertions

#assert_generates, #assert_recognizes, #assert_routing, #with_routing

Methods included from Assertions::ResponseAssertions

#assert_redirected_to, #assert_response

Methods included from Assertions::DomAssertions

#assert_dom_equal, #assert_dom_not_equal

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

Delegate unhandled messages to the current session instance.



380
381
382
383
384
385
386
387
388
389
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 380

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 Method Details

#appObject



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

def app
  @app ||= nil
end

#copy_session_variables!Object

Copy the instance variables from the current session instance into the test instance.



358
359
360
361
362
363
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 358

def copy_session_variables! #:nodoc:
  return unless integration_session
  %w(controller response request).each do |var|
    instance_variable_set("@#{var}", @integration_session.__send__(var))
  end
end

#default_url_optionsObject



365
366
367
368
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 365

def default_url_options
  reset! unless integration_session
  integration_session.default_url_options
end

#default_url_options=(options) ⇒ Object



370
371
372
373
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 370

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

#open_session(app = nil) ⇒ Object

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.



350
351
352
353
354
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 350

def open_session(app = nil)
  dup.tap do |session|
    yield session if block_given?
  end
end

#reset!Object

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



324
325
326
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 324

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

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

Returns:

  • (Boolean)


375
376
377
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 375

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