sequel-rails icon indicating copy to clipboard operation
sequel-rails copied to clipboard

Transactional Unit Tests

Open tadman opened this issue 15 years ago • 1 comments

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

tadman avatar Aug 09 '10 17:08 tadman

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

wolfmanjm avatar Dec 23 '10 08:12 wolfmanjm