From 4b2f666b366ca115a4ca7b6613325a882159dac4 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Fri, 30 Mar 2018 13:04:15 -0400 Subject: [PATCH] Replace `poltergeist` with `capybara-selenium` 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`. --- .travis.yml | 4 +++- bin/setup_ci | 11 +++++++++++ ember-cli-rails.gemspec | 1 + spec/spec_helper.rb | 6 +----- spec/support/capybara.rb | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 spec/support/capybara.rb diff --git a/.travis.yml b/.travis.yml index 920546c0..d445c6f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: ruby -sudo: false +sudo: required +addons: + chrome: stable cache: - bundler notifications: diff --git a/bin/setup_ci b/bin/setup_ci index 26e7c68d..419e50bf 100755 --- a/bin/setup_ci +++ b/bin/setup_ci @@ -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 @@ -20,4 +29,6 @@ node --version gem update --system +install_chromedriver + source bin/setup diff --git a/ember-cli-rails.gemspec b/ember-cli-rails.gemspec index 0b261b59..9f0ed948 100644 --- a/ember-cli-rails.gemspec +++ b/ember-cli-rails.gemspec @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7e636942..606780eb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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| @@ -26,5 +24,3 @@ config.infer_spec_type_from_file_location! config.order = :random end - -Capybara.javascript_driver = :poltergeist diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb new file mode 100644 index 00000000..f63faa6e --- /dev/null +++ b/spec/support/capybara.rb @@ -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