Module: ActionDispatch::Integration::Runner
- Includes:
 - Assertions
 
- Included in:
 - ActionDispatch::IntegrationTest::Behavior
 
- Defined in:
 - actionpack/lib/action_dispatch/testing/integration.rb
 
Constant Summary collapse
- APP_SESSIONS =
 {}
Constants included from Assertions::ResponseAssertions
Assertions::ResponseAssertions::RESPONSE_PREDICATES
Instance Attribute Summary collapse
- 
  
    
      #app  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute app.
 - 
  
    
      #root_session  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
:nodoc:.
 
Instance Method Summary collapse
- 
  
    
      #assertions  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #assertions=(assertions)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #before_setup  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #copy_session_variables!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Copy the instance variables from the current session instance into the test instance.
 - #create_session(app) ⇒ Object
 - #default_url_options ⇒ Object
 - #default_url_options=(options) ⇒ Object
 - #initialize(*args, &blk) ⇒ Object
 - #integration_session ⇒ Object
 - 
  
    
      #open_session  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Open a new session instance.
 - 
  
    
      #remove!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #reset!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Reset the current session.
 
Methods included from Assertions
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Methods included from Assertions::RoutingAssertions
#assert_generates, #assert_recognizes, #assert_routing, #setup, #with_routing
Methods included from Assertions::ResponseAssertions
#assert_redirected_to, #assert_response
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object (private)
Delegate unhandled messages to the current session instance.
      442 443 444 445 446 447 448 449 450  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 442 def method_missing(method, ...) if integration_session.respond_to?(method) integration_session.public_send(method, ...).tap do copy_session_variables! end else super end end  | 
  
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
      339 340 341  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 339 def app @app end  | 
  
#root_session ⇒ Object
:nodoc:
      340 341 342  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 340 def root_session @root_session end  | 
  
Instance Method Details
#assertions ⇒ Object
:nodoc:
      412 413 414  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 412 def assertions # :nodoc: root_session ? root_session.assertions : super end  | 
  
#assertions=(assertions) ⇒ Object
:nodoc:
      416 417 418  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 416 def assertions=(assertions) # :nodoc: root_session ? root_session.assertions = assertions : super end  | 
  
#before_setup ⇒ Object
:nodoc:
      347 348 349 350  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 347 def before_setup # :nodoc: @app = nil super end  | 
  
#copy_session_variables! ⇒ Object
Copy the instance variables from the current session instance into the test instance.
      422 423 424 425 426  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 422 def copy_session_variables! # :nodoc: @controller = @integration_session.controller @response = @integration_session.response @request = @integration_session.request end  | 
  
#create_session(app) ⇒ Object
      362 363 364 365 366 367 368 369 370 371 372  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 362 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  | 
  
#default_url_options ⇒ Object
      428 429 430  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 428 def integration_session. end  | 
  
#default_url_options=(options) ⇒ Object
      432 433 434  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 432 def () integration_session. = end  | 
  
#initialize(*args, &blk) ⇒ Object
      342 343 344 345  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 342 def initialize(*args, &blk) super(*args, &blk) @integration_session = nil end  | 
  
#integration_session ⇒ Object
      352 353 354  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 352 def integration_session @integration_session ||= create_session(app) end  | 
  
#open_session ⇒ 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.
      404 405 406 407 408 409 410  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 404 def open_session dup.tap do |session| session.reset! session.root_session = self.root_session || self yield session if block_given? end end  | 
  
#remove! ⇒ Object
:nodoc:
      374 375 376  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 374 def remove! # :nodoc: @integration_session = nil end  | 
  
#reset! ⇒ Object
Reset the current session. This is useful for testing multiple sessions in a single test case.
      358 359 360  | 
    
      # File 'actionpack/lib/action_dispatch/testing/integration.rb', line 358 def reset! @integration_session = create_session(app) end  |