Module: Cucumber::Rails

Defined in:
lib/gems/cucumber-0.1.15/lib/cucumber/rails/world.rb

Defined Under Namespace

Classes: World

Class Method Summary collapse

Class Method Details

.use_transactional_fixturesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rails/world.rb', line 44

def self.use_transactional_fixtures
  World.use_transactional_fixtures = true
  if defined?(ActiveRecord::Base)
    $cucumber_toplevel.Before do
      if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
        ActiveRecord::Base.connection.increment_open_transactions
      else
        ActiveRecord::Base.__send__(:increment_open_transactions)
      end
      ActiveRecord::Base.connection.begin_db_transaction
      ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
    end
    
    $cucumber_toplevel.After do
      ActiveRecord::Base.connection.rollback_db_transaction
      if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
        ActiveRecord::Base.connection.decrement_open_transactions
      else
        ActiveRecord::Base.__send__(:decrement_open_transactions)
      end
    end
  end
end