Conditionally enable Poltergeist with Capybara

Poltergeist is a driver for Capybara that allows you to run tests on a headless Webkit browser provided by PhantomJS. Minus all those fancy words, it means your javascript tests are run inside a real browser that can execute javascript in order to simulate a real webpage. But… it’s slow and sometimes you need features it doesn’t have, like being able to programmatically POST (looking at you stripe webhook tests).

If you want to conditionally enable it for a specific rspec suite, here’s a snippet that should save your day and make your test suite faster:

 

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *