Upgrading capybara from 1.0.1 to 1.1.4 makes database_cleaner break my specs
I got around this issue in cucumber by placing
sleep 0.2
at the end of the step (or in your case "spec") that does some AJAX stuff. I imagine what happens is that cucumber/rspec calls database cleaner while the JS driver is still waiting for the ajax response.
The fix isn't to use sleep
but to only use Capybara API methods as they wait for what's expected.
Below, line 2 fails (as current_path
is non-waiting, but line 3 works (as has_selector?
waits). The link to Jonas Nicklas' article below explains it well.
click_on 'signup_button' # Which does an AJAX redirect to /dashboardassert_equal dashboard_path, current_path # This causes the deadlock error as Capybara doesn't wait.assert page.has_selector?("#dashboard") # This works as it causes Capybara to wait for the new page.
http://www.elabs.se/blog/53-why-wait_until-was-removed-from-capybara
The solution we use is to find something in the page that should change in response to a successful ajax call. So something like:
click_on('Save')expect(page).to have_content('Saved')