Transactional Unit Tests #1

Open
tadman opened this Issue Aug 9, 2010 · 1 comment

2 participants

@tadman

With ActiveRecord missing, the transactional_fixtures feature must be disabled, but this has the side-effect of turning off transactions for unit tests.

I've searched for a method to re-engage this with no luck, so as an alternative I've created a quick work-around that wraps the test runner in a transaction that's rolled back:

http://gist.github.com/515753

@wolfmanjm

For RSpec 2 this can be done by adding an around block...

around(:each) do |example|
  Sequel::DATABASES.first.transaction do
    example.run
    raise Sequel::Error::Rollback
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment