Module: Merb::Test::Helpers::DataMapper::ClassMethods

Included in:
World::Base
Defined in:
lib/merb_cucumber/helpers/datamapper.rb

Instance Method Summary collapse

Instance Method Details

#use_transactional_fixturesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/merb_cucumber/helpers/datamapper.rb', line 8

def use_transactional_fixtures
  $main.Before do
    repository(:default) do
      transaction = ::DataMapper::Transaction.new(repository)
      transaction.begin
      repository.adapter.push_transaction(transaction)
    end
  end

  $main.After do
    repository(:default) do
      while repository.adapter.current_transaction
        repository.adapter.current_transaction.rollback
        repository.adapter.pop_transaction
      end
    end
  end
end