Module: ActionDispatch::Integration::Runner
- Extended by:
- ActiveSupport::Concern
- Includes:
- Assertions, Routing::UrlFor
- Included in:
- ActionDispatch::IntegrationTest
- Defined in:
- lib/action_dispatch/testing/integration.rb
Constant Summary
Constants included from Assertions
Instance Method Summary collapse
- #app ⇒ Object
-
#copy_session_variables! ⇒ Object
Copy the instance variables from the current session instance into the test instance.
-
#method_missing(sym, *args, &block) ⇒ Object
Delegate unhandled messages to the current session instance.
-
#open_session(app = nil) ⇒ Object
Open a new session instance.
-
#reset! ⇒ Object
Reset the current session.
- #url_options ⇒ Object
Methods included from Routing::UrlFor
Methods included from Routing::PolymorphicRoutes
#polymorphic_path, #polymorphic_url
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.
365 366 367 368 369 370 371 372 373 374 |
# File 'lib/action_dispatch/testing/integration.rb', line 365 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
#app ⇒ Object
309 310 311 |
# File 'lib/action_dispatch/testing/integration.rb', line 309 def app @app end |
#copy_session_variables! ⇒ Object
Copy the instance variables from the current session instance into the test instance.
349 350 351 352 353 354 |
# File 'lib/action_dispatch/testing/integration.rb', line 349 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 |
#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.
341 342 343 344 345 |
# File 'lib/action_dispatch/testing/integration.rb', line 341 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.
315 316 317 |
# File 'lib/action_dispatch/testing/integration.rb', line 315 def reset! @integration_session = Integration::Session.new(app) end |
#url_options ⇒ Object
359 360 361 362 |
# File 'lib/action_dispatch/testing/integration.rb', line 359 def reset! unless @integration_session @integration_session. end |