I volunteered at Railsbridge yesterday & when the other teachers didn't seem busy enough I went ahead & asked them questions of my own. I learned about the save_and_open_page method in Rspec.

This gave me the power to go fix a bunch of feature tests that I previously couldn't figure out how to fix, usually the features were working but the tests were failing falsely.

Finally I got to one that got the better of me again. It was a page that loaded a "Flash" message but didn't reload the page. I asked for help again and someone explained to me that the Silenium Web Driver that is the default web driver for Rspec isn't capable of seeing these sort of Javascript changes to the page if it doesn't reload, it only inspects HTML but doesn't launch a full headless web browser. What I needed was a gem called 'poltergeist' which would let me use phantomjs which would give me this capability. Here is how I fixed it.

Install PhantomJS


Switch from Selenium to Poltergeist


Lastly, since phantomjs will be running in a different thread, unexpected things could happen in the test database. Here is a post by Avdi that explains how & why to fix it.


Before I could finish the last step I noticed that something else was wrong with the spec, I forgot to let it click a link. So now my tests are fixed and this process is not done, but hopefully writing it down for when I do need it will make it less painful at that time.