Created
August 14, 2017 10:23
-
-
Save adaRn/f9d7d3d6cd310e1e3dd6fb804156eb60 to your computer and use it in GitHub Desktop.
Revisions
-
adaRn created this gist
Aug 14, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ ## Solution: In your `helper` change ```ruby config.after(:each) do DatabaseCleaner.clean end ``` to ```ruby config.append_after(:each) do DatabaseCleaner.clean end ``` ### Why this works? `after` is in fact an alias for `prepend_after`, which means `DatabaseCleaner.clean` will run before Capybara and its drivers terminate all connections. Stopping Capybara first and then cleaning the database will ensure no errors will arise from requests that Capybara's driver makes because of already cleaned database. The requests that are yielding errors don't even necessarily have to be explicitly issued by you - it's enough that one of tons of requests that a browser makes fails.