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

README, suggest append_after to ensure proper order of cleanup #414

Merged
merged 1 commit into from Jan 15, 2016

Conversation

jrochkind
Copy link
Contributor

It's best to have DatabaseCleaner.clean run AFTER capybara cleanup, in case capybara cleanup ends up triggering anything that could be interrupted by the database cleaner.

require 'capybara/rspec' installs an after hook for Capybara cleanup.

rspec after hooks are run in reverse order of definition, after hooks defined last are run first. So with require 'capybara/rspec' at top of file, and then later manually defining an after hook for DC cleanup... DC cleanup fires before capybara's cleanup.

Using RSpec's append_after instead of after fixes this. With so many timing issues that can go wrong with capybara, might as well eliminate one more potential one.

@etagwerker etagwerker self-assigned this Dec 31, 2015
@etagwerker etagwerker added the doc label Dec 31, 2015
@etagwerker
Copy link
Member

@jrochkind Good point! Could you fix the conflict and update this PR? After that I'd be happy to merge this.

It's best to have DatabaseCleaner.clean run AFTER capybara cleanup, in case capybara cleanup ends up triggering anything that could be interrupted by the database cleaner.

`require 'capybara/rspec'` installs an after hook for Capybara cleanup.

rspec after hooks are run in _reverse_ order of definition, after hooks defined last are run first. So with `require 'capybara/rspec'` at top of file, and then later manually defining an after hook for DC cleanup... DC cleanup fires before capybara's cleanup.

Using RSpec's `append_after` instead of `after` fixes this. With so many timing issues that can go wrong with capybara, might as well eliminate one more potential one.
@jrochkind
Copy link
Contributor Author

done

@etagwerker
Copy link
Member

@jrochkind wonderful, thanks! 👍

etagwerker added a commit that referenced this pull request Jan 15, 2016
README, suggest append_after to ensure proper order of cleanup
@etagwerker etagwerker merged commit 1cab518 into DatabaseCleaner:master Jan 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants