Method deprecated
This method is deprecated on the latest stable version of Rails.
The last existing version (v1.2.6) is shown here.
open_session()
public
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
def open_session
session = Integration::Session.new
extras = Module.new { attr_accessor :delegate, :test_result }
self.class.fixture_table_names.each do |table_name|
name = table_name.tr(".", "_")
next unless respond_to?(name)
extras.send(:define_method, name) { |*args| delegate.send(name, *args) }
end
extras.send(:define_method, :add_assertion) { test_result.add_assertion }
session.extend(extras)
session.delegate = self
session.test_result = @_result
yield session if block_given?
session
end