Created
July 31, 2012 05:02
-
-
Save yclian/3213816 to your computer and use it in GitHub Desktop.
RSpec helper that starts and rolls (back) a transaction
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
module DataMapperHelper | |
end | |
RSpec.configure do |c| | |
# See: http://rhnh.net/2010/10/06/transactional-before-all-with-rspec-and-datamapper | |
[:all, :each].each do |s| | |
c.before s, :type => :api do | |
repository :default do |r| | |
t = DataMapper::Transaction.new(repository) | |
t.begin | |
r.adapter.push_transaction(t) | |
end | |
end | |
c.after s, :type => :api do | |
repository(:default).adapter.pop_transaction.rollback | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment