Created
September 19, 2009 22:24
-
-
Save beccasaurus/189609 to your computer and use it in GitHub Desktop.
How to easily do transactional specs using DataMapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/support' | |
Spec::Runner.configure do |config| | |
transactional_specs(config) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transactional_specs rspec_config | |
rspec_config.before do | |
@_spec_transaction = DataMapper::Transaction.new DataMapper.repository(:default).adapter | |
@_spec_transaction.begin | |
DataMapper.repository(:default).adapter.push_transaction @_spec_transaction | |
end | |
rspec_config.after do | |
DataMapper.repository(:default).adapter.pop_transaction | |
@_spec_transaction.rollback | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment