Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database cleaner; truncate not fully overriding transaction #153

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

database cleaner; truncate not fully overriding transaction #153

cmeiklejohn opened this issue Jul 6, 2011 · 4 comments

Comments

@cmeiklejohn
Copy link

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
Copy link

tmiller commented Sep 13, 2011

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
Copy link
Author

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
Copy link
Author

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

@cmeiklejohn cmeiklejohn reopened this Oct 11, 2011
@aslakhellesoy
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants