I’m developing on a Nitrous box so to run any feature tests involving JS I use PhantomJS installed as one of their ‘Autoparts’. I’m using the Poltergeist gem, installed and configured as per the gem’s docs.
I’m getting a consistent failure behavior where the test scenario after one with
js: true fails with an error like this:
Failure/Error: click_button 'Sign in' RuntimeError: Called id for nil, # etc
If I write a simple test:
feature 'User signs in' do scenario 'with valid details' do user = create(:user) visit sign_in_path fill_in 'Email', with: @user.email fill_in 'Password', with: 'password' click_button 'Sign in' expect(page).to have_content('Welcome') end end
then duplicate the scenario a few times in the spec file and change one of them to read:
scenario 'with valid details WITH JS', js: true do
then I get a consistent results:
with valid details with valid details WITH JS with valid details (FAILED - 1)
It’s always the test after the JS test that fails. I’ve looked through the
test.log but it all looks fine until the
500 internal server error line then it just stops.
I’ve read a lot about shared database connections but when I tried adding the lines suggested here: http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/ I get the same results with or without it.
I’m using Database Cleaner with the standard setup suggested by Avdi Grimm (who advises against the use of the ‘shared db connection’ technique).
The fact that it’s the test after the JS test that always fails seems to point to a problem with cleaning the database but all my other 200+ tests run fine. The only problems I have are with feature tests that require JS.
Any pointers would be most welcome.