Methods
Public Class methods
[ show source ]
# File actionpack/lib/action_controller/integration.rb, line 488 488: def initialize(*args) 489: super 490: @integration_session = nil 491: end
Public Instance methods
Delegate unhandled messages to the current session instance.
[ show source ]
# File actionpack/lib/action_controller/integration.rb, line 558 558: def method_missing(sym, *args, &block) 559: reset! unless @integration_session 560: if @integration_session.respond_to?(sym) 561: returning @integration_session.__send__(sym, *args, &block) do 562: copy_session_variables! 563: end 564: else 565: super 566: end 567: end
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.
[ show source ]
# File actionpack/lib/action_controller/integration.rb, line 521 521: def open_session(application = nil) 522: session = Integration::Session.new(application) 523: 524: # delegate the fixture accessors back to the test instance 525: extras = Module.new { attr_accessor :delegate, :test_result } 526: if self.class.respond_to?(:fixture_table_names) 527: self.class.fixture_table_names.each do |table_name| 528: name = table_name.tr(".", "_") 529: next unless respond_to?(name) 530: extras.__send__(:define_method, name) { |*args| 531: delegate.send(name, *args) 532: } 533: end 534: end 535: 536: # delegate add_assertion to the test case 537: extras.__send__(:define_method, :add_assertion) { 538: test_result.add_assertion 539: } 540: session.extend(extras) 541: session.delegate = self 542: session.test_result = @_result 543: 544: yield session if block_given? 545: session 546: end
Reset the current session. This is useful for testing multiple sessions in a single test case.
[ show source ]
# File actionpack/lib/action_controller/integration.rb, line 495 495: def reset! 496: @integration_session = open_session 497: end