Module: ActionDispatch::Integration::Runner
- Includes:
- Assertions
- Included in:
- ActionDispatch::IntegrationTest
- Defined in:
- lib/action_dispatch/testing/integration.rb
Instance Method Summary collapse
- #app ⇒ Object
-
#copy_session_variables! ⇒ Object
Copy the instance variables from the current session instance into the test instance.
- #default_url_options ⇒ Object
- #default_url_options=(options) ⇒ Object
-
#method_missing(sym, *args, &block) ⇒ Object
Delegate unhandled messages to the current session instance.
-
#open_session ⇒ Object
Open a new session instance.
-
#remove! ⇒ Object
:nodoc:.
-
#reset! ⇒ Object
Reset the current session.
- #respond_to?(method, include_private = false) ⇒ Boolean
Methods included from Assertions
Methods included from Assertions::RoutingAssertions
#assert_generates, #assert_recognizes, #assert_routing, #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(sym, *args, &block) ⇒ Object
Delegate unhandled messages to the current session instance.
392 393 394 395 396 397 398 399 400 401 |
# File 'lib/action_dispatch/testing/integration.rb', line 392 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
320 321 322 |
# File 'lib/action_dispatch/testing/integration.rb', line 320 def app @app ||= nil end |
#copy_session_variables! ⇒ Object
Copy the instance variables from the current session instance into the test instance.
370 371 372 373 374 375 |
# File 'lib/action_dispatch/testing/integration.rb', line 370 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_options ⇒ Object
377 378 379 380 |
# File 'lib/action_dispatch/testing/integration.rb', line 377 def reset! unless integration_session integration_session. end |
#default_url_options=(options) ⇒ Object
382 383 384 385 |
# File 'lib/action_dispatch/testing/integration.rb', line 382 def () reset! unless integration_session integration_session. = 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.
362 363 364 365 366 |
# File 'lib/action_dispatch/testing/integration.rb', line 362 def open_session dup.tap do |session| yield session if block_given? end end |
#remove! ⇒ Object
:nodoc:
330 331 332 |
# File 'lib/action_dispatch/testing/integration.rb', line 330 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.
326 327 328 |
# File 'lib/action_dispatch/testing/integration.rb', line 326 def reset! @integration_session = Integration::Session.new(app) end |
#respond_to?(method, include_private = false) ⇒ Boolean
387 388 389 |
# File 'lib/action_dispatch/testing/integration.rb', line 387 def respond_to?(method, include_private = false) integration_session.respond_to?(method, include_private) || super end |