| Module | ActionController::Integration::Runner |
| In: |
vendor/rails/actionpack/lib/action_controller/integration.rb
|
# File vendor/rails/actionpack/lib/action_controller/integration.rb, line 484
484: def initialize(*args)
485: super
486: @integration_session = nil
487: end
Delegate unhandled messages to the current session instance.
# File vendor/rails/actionpack/lib/action_controller/integration.rb, line 554
554: def method_missing(sym, *args, &block)
555: reset! unless @integration_session
556: if @integration_session.respond_to?(sym)
557: returning @integration_session.__send__(sym, *args, &block) do
558: copy_session_variables!
559: end
560: else
561: super
562: end
563: 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.
# File vendor/rails/actionpack/lib/action_controller/integration.rb, line 517
517: def open_session(application = nil)
518: session = Integration::Session.new(application)
519:
520: # delegate the fixture accessors back to the test instance
521: extras = Module.new { attr_accessor :delegate, :test_result }
522: if self.class.respond_to?(:fixture_table_names)
523: self.class.fixture_table_names.each do |table_name|
524: name = table_name.tr(".", "_")
525: next unless respond_to?(name)
526: extras.__send__(:define_method, name) { |*args|
527: delegate.send(name, *args)
528: }
529: end
530: end
531:
532: # delegate add_assertion to the test case
533: extras.__send__(:define_method, :add_assertion) {
534: test_result.add_assertion
535: }
536: session.extend(extras)
537: session.delegate = self
538: session.test_result = @_result
539:
540: yield session if block_given?
541: session
542: end