-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
Default cucumber rails database_cleaner hook is suboptimal #215
Comments
If you don't want the hook to run, just tag your scenario with Or did I misunderstand what you're trying to achieve? P.S. Your emotions don't add value to the conversation |
What should I do if I need all of my features to behave as if they has this '@no-database-cleaner'? I think the hook should be removed instead. It's too magical for me as of now. P.S. Sorry for being uncool. Some time banging your head against wall is not so fun. |
It's not clear to me what you're trying to accomplish. Not run DBcleaner at all for all scenarios? Always run, but use different strategies? You can do that with another hook. You might want to start a thread on the mailing list to get advice from more people |
Okay, I rephrased the issue description. |
Was this thread taken to the mailing list? Here are my experiences with the database_cleaner and the default hooks. I too have a need to run scenarios without calling database_cleaner. In my case it's just a few scenarios (each tagged as I believe @phuongnd08 should be able to set In my particular case, it's just the As it currently is now, there is no way to disable or override the |
The fact that I recognize that most users will probably not be using sqlite and thus won't ever see this error, but it's a curious failure nonetheless. Edit: FWIW I got here after bombing out on the initial Further edit: I checked the gemspec and database-cleaner is a dev dependency but not a test dependency. I put Thanks! |
@phuongnd08 Can't you just place some code like the following in Before('@truncation') do
DatabaseCleaner.strategy = :truncation
end
Before('~@truncation') do
DatabaseCleaner.strategy = :transaction
end This will change the strategy before the cucumber-rails hook calls |
I'm just catching up on this. If I understand correctly, a minority of cucumber-rails users would prefer for Maybe we should add some kind of configuration block to allow you to opt out of the hook loading? |
@mattwynne That sounds like a great solution. I prefer that the database is not cleaned up after each run. It is very helpful in debugging. Also, I sometimes use those wonderful cucumber steps to setup demo data in my development database. Technically, we just need too make sure the system is in correct state before starting a test. Unfortunately, the @no-database-cleaner tag disables DatabaseCleaner completely. Is there a way to override the |
I think having the option to prevent this would definitely be nice. Adding Totally understand if this is low priority though, given the existence of a workaround. I'd be happy to submit a PR if you'd be interested (and could give a pointer or two in terms of how/where you'd like it done). Cheers, |
Thanks @urbanautomaton - a pull request is definitely the way forward here. All I'd ask is that you try to include tests in your patch, but I'll give you some help with that if you're not sure how to do it. Once we have some code we'll have something more concrete to discuss. |
The hooks that automatically invoke database_cleaner before every scenario can sometimes cause problems when switching cleaning strategies between scenarios (issue cucumber#215). To allow a user to take full control of when database_cleaner is invoked, the configuration option Cucumber::Rails::Database.autorun_database_cleaner is provided, defaulting to true.
Closing old issues. If they are still relevant, please reopen |
The default cucumber rails database_cleaner hook make a call to DatabaseCleaner.start, which in some cases will cause the transaction mode to begin. Under that condition, the test is unstable as it raises "This connection is still waiting for a result" or "Mysql2::Error: SAVEPOINT active_record_1 does not exist" (This is a very notorious problem happen with the combination of Cucumber + Capybara + Mysql)
Developer should be able to explicitly change the DatabaseCleaner strategy before calling DatabaseCleaner.start, which may be impossible because the shipped hook may run first. So, the hook should be removed instead
The text was updated successfully, but these errors were encountered: