Skip to content

Commit

Permalink
Replace poltergeist with capybara-selenium
Browse files Browse the repository at this point in the history
Fix CI Failures by executing feature tests against a headless Chrome
browser instead of PhantomJS.

Configure CI to use the `chrome` stable addon. Add a step to
`bin/setup_ci` to install `chromedriver`.
  • Loading branch information
seanpdoyle committed Mar 30, 2018
1 parent 81bb2b3 commit 4b2f666
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: ruby
sudo: false
sudo: required
addons:
chrome: stable
cache:
- bundler
notifications:
Expand Down
11 changes: 11 additions & 0 deletions bin/setup_ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

set -e

install_chromedriver() {
wget -N http://chromedriver.storage.googleapis.com/2.30/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm -v ~/chromedriver_linux64.zip
sudo mv -v -f ~/chromedriver /usr/local/share/
sudo chmod -v +x /usr/local/share/chromedriver
sudo ln -v -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
}

rm -rf ~/.nvm

git clone https://github.com/creationix/nvm.git ~/.nvm
Expand All @@ -20,4 +29,6 @@ node --version

gem update --system

install_chromedriver

source bin/setup
1 change: 1 addition & 0 deletions ember-cli-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "generator_spec", "~> 0.9.0"
spec.add_development_dependency "rspec-rails", "~> 3.6.0"

spec.add_development_dependency "capybara-selenium"
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.6.0"
end
6 changes: 1 addition & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
ENV["RAILS_ENV"] = "test"

require "dummy/application"

require "rspec/rails"
require "capybara/poltergeist"

Dummy::Application.initialize!

Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
Dir["spec/support/**/*.rb"].sort.each { |file| require "./#{file}" }

RSpec.configure do |config|
config.expect_with :rspec do |expectations|
Expand All @@ -26,5 +24,3 @@
config.infer_spec_type_from_file_location!
config.order = :random
end

Capybara.javascript_driver = :poltergeist
19 changes: 19 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "selenium/webdriver"

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) },
)

Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities,
)
end

Capybara.javascript_driver = :headless_chrome

0 comments on commit 4b2f666

Please sign in to comment.