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

Ensure database cleaner won't run until after Capybara has finished loading pages to stop false negative failures #117

Open
eliotsykes opened this issue Mar 2, 2016 · 0 comments

Comments

@eliotsykes
Copy link
Owner

Details: DatabaseCleaner/database_cleaner@a8bb2cb

Ensure database cleaner won't run until after Capybara has finished loading pages to stop false negative failures.

This can manifest itself if a page is still rendering when a Capybara test finishes without an expectation, e.g.:

  1. Spec example has final line with an action to load a page, e.g. click_link "Next" without an expectation to check the action completed successfully.
  2. While the page render triggered by step 1 is still in progress, database cleaner truncates tables that the page render is dependent on.
  3. RSpec detects exceptions raised during page render and fails the test. These failures are hard to debug as they have no accompanying expectation.

To fix, ensure the database cleaner doesn't start until after Capybara has finished its work:

--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -55,7 +55,7 @@ RSpec.configure do |config|
     DatabaseCleaner.start
   end

-  config.after(:each) do
+  config.append_after(:each) do
     DatabaseCleaner.clean
   end
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

1 participant