database cleaner; truncate not fully overriding transaction #153

Closed
cmeiklejohn opened this Issue Jul 6, 2011 · 4 comments

Projects

None yet

3 participants

@cmeiklejohn

I have my default database cleaner strategy set to transaction, an before block setting it to truncation for @no-txn tagged features/scenarios and a bunch of features tagged @no-txn.

In my features/support/env.rb I have the following:

begin
  DatabaseCleaner.strategy = :transaction
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

Before('@no-txn') do
  DatabaseCleaner.strategy = :truncation
end

However, I'm running into failing scenarios because they are trying to rollback to savepoints that don't exist.

I do not run into the problem if I set the following:

begin
  DatabaseCleaner.strategy = :truncation
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

We're using:

  • cucumber (1.0.0)
  • cucumber-rails (1.0.2)
@tmiller

This is happening because cucumber-rails is using a before hook in the library to call DatabaseCleaner.setup. This causes DatabaseCleaner.setup to be called before your hook to set the strategy, thus causing it to break because you must set the strategy before calling start.

@cmeiklejohn

I'm not experiencing the problem now, and I'm assuming that I must have shuffled things around thus avoiding the situation you describe. Thanks for your comment!

@cmeiklejohn

@tmiller This was not the case for me -- no call to DatabaseCleaner.setup...

@cmeiklejohn cmeiklejohn reopened this Oct 11, 2011
@aslakhellesoy
Cucumber member

I believe this is fixed by #166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment