Switching from Selenium to Poltergeist in RSpec feature specs
In my own work, I use Poltergeist for these tests. Poltergeist is a Ruby wrapper for the PhantomJS headless browser, so you’ll have to install PhantomJS first. I recommend using your operating system’s built-in package manager to do this, when possible. On my Mac, I use Homebrew (
brew install phantomjs). If you’re on Windows, or just not sure, download and run the installer.
group :test do
# Other testing gems ...
# Go ahead and remove selenium-webdriver, if needed
bundle install to install the gem.
Next, configure RSpec to use it. Add the following to your spec/rails_helper.rb file. (If you’re still using RSpec 2.x, you’ll add this to spec/spec_helper.rb):
In addition to speeding up your test runs, Poltergeist provides some advanced features. I don’t use these often, but they are handy from time to time, particularly for debugging tests. I encourage you to refer to Poltergeist’s README to learn more.
blog comments powered by
Rails testing made simple
Learn to test Rails apps the way
I learned, building up tests step-by-step, in
Everyday Rails Testing
Expanded to include exclusive content and a complete sample Rails application.
Learn more »