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

Cannot change database_cleaner strategy between scenario #180

Closed
phuong-nguyen opened this issue Oct 12, 2011 · 4 comments
Closed

Cannot change database_cleaner strategy between scenario #180

phuong-nguyen opened this issue Oct 12, 2011 · 4 comments

Comments

@phuong-nguyen
Copy link

I want to use transaction strategy for Rack Test and truncation strategy for Selenium test but cucumber rails make it impossible by adding a Before hook that call DatabaseCleaner.start. I want to change the strategy before DatabaseCleaner.start called, but cannot figure it out, since all hooks are appended. This make our test much slower.

@aslakhellesoy
Copy link
Contributor

Did you try to define your own hooks before the built-in ones are defined?

# env.rb

Before('@javascript') do
   DatabaseCleaner.strategy = :truncation
end

After('@javascript') do
   DatabaseCleaner.strategy = DatabaseCleaner.default_strategy
end

# This defines the default hooks
require 'cucumber/rails'
...

@phuong-nguyen
Copy link
Author

Thanks for the tip. It works. But since DatabaseCleaner.default_strategy doesn't exist (anymore?), I replaced it with :transaction.

@aslakhellesoy
Copy link
Contributor

I'm reopening this just so I remember to put better instructions in the generated files.

@aslakhellesoy
Copy link
Contributor

Obsolete by the fix of #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

2 participants