in Development, Rails

Headless javascript tests with poltergeist and Ubuntu

If you already have a nodejs dependency, I recommend the following solution for headless testing instead of my first one.

Poltergeist needs nodejs and phantomjs to run. There are several ways to install them. I recommend the easiest one: with the built-in package manager. A handy tutorial can be found at https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server. BTW: I recommend digging through the tutorial section at digital ocean.

Then add these lines to your Gemfile:

group :development, :test do
  gem 'rspec-rails'
  gem 'capybara'
  gem 'poltergeist'
end

/spec/rails_helper.rb

...
require 'capybara/poltergeist'
...
Capybara.javascript_driver = :poltergeist
...