Sha256: f1b2f4c639eec019ad5db0ee023b6e2c6df4d3e455a8c943c2d797a241c794a6

Contents?: true

Size: 939 Bytes

Versions: 3

Compression:

Stored size: 939 Bytes

Contents

if defined?(ActiveRecord::Base)
  Cucumber::Rails::World.use_transactional_fixtures = true
  
  Before do
    @__cucumber_ar_connection = ActiveRecord::Base.connection
    if @__cucumber_ar_connection.respond_to?(:increment_open_transactions)
      @__cucumber_ar_connection.increment_open_transactions
    else
      ActiveRecord::Base.__send__(:increment_open_transactions)
    end
    @__cucumber_ar_connection.begin_db_transaction
    ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
  end
  
  After do
    @__cucumber_ar_connection.rollback_db_transaction
    if @__cucumber_ar_connection.respond_to?(:decrement_open_transactions)
      @__cucumber_ar_connection.decrement_open_transactions
    else
      ActiveRecord::Base.__send__(:decrement_open_transactions)
    end
  end
else
  module Cucumber::Rails
    def World.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
aslakhellesoy-cucumber-0.3.101.2 lib/cucumber/rails/active_record.rb
aslakhellesoy-cucumber-0.3.102 lib/cucumber/rails/active_record.rb
cucumber-0.3.102 lib/cucumber/rails/active_record.rb