While still not 100% sure what caused this, removing Capybara.automatic_reload = false
from the tests using capybara-webkit resolved the issue.
Why do a series of specs fail when each single spec succeeds?
-
30-05-2022 - |
Question
On Capybara 2.1.0 with Rspec 2.12.0:
If I run $ rspec spec/features/user_sees_leaderboard_spec.rb
, the spec passes.
If I run $ rspec spec/features/*
, the test fails, claiming:
Capybara::ElementNotFound:
Unable to find css "#flash"
If I do save_and_open_page
, #flash is present and visible.
Here's the helper where the failure is occurring:
def sign_in_as(user)
visit new_user_session_path
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Sign In"
flash = find("#flash")
flash.should have_content "You are now signed in."
end
Any ideas? I'm new-ish to Capybara so not sure where to start. Thanks!
EDIT/UPDATE:
By doing save_and_open_page
on a set of specs that fail when run together I was able to see a series of successes followed by a series of pages saying nothing besides "Not Found" in the body tag. Google didn't turn up anything – thoughts?
UPDATE #2
I noticed that the "Not Found" content in BODY began just after a spec that used capybara-webkit to run javascript. Even explicitly resetting Capybara.current_driver = :rack_test in an after(:all) block doesn't fix the issue, but I think this is relevant.
Solution