Skip to content

Commit

Permalink
Switch from Poltergeist to headless Chrome
Browse files Browse the repository at this point in the history
Poltergeist is no longer maintained
Rails 5.1 introduces ActionDispatch::SystemTestCase which should allow
our feature tests to be speed up when this is done:
rspec/rspec-rails#1813
  • Loading branch information
jcoyne committed Jun 20, 2017
1 parent bd63332 commit aa67444
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
sudo: false
sudo: required
language: ruby
notifications:
email: false
dist: trusty
rvm:
- 2.4.1

# We provide AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY encrypted by travis here
env:
global:
Expand All @@ -30,14 +29,15 @@ addons:
before_install:
- gem update --system
- gem install bundler
- "phantomjs --version"
- "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
- "if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
- "phantomjs --version"
- sudo apt-get update
- sudo apt-get install chromium-chromedriver
- chrome --version

before_script:
- "export PATH=$PATH:/usr/lib/chromium-browser/"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- bundle exec rake db:create

before_deploy:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'poltergeist'
gem 'rails-controller-testing'
gem 'selenium-webdriver'
gem 'webmock'
end

Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ GEM
carrierwave-aws (1.1.0)
aws-sdk (~> 2.0)
carrierwave (>= 0.7, < 2.0)
childprocess (0.7.0)
ffi (~> 1.0, >= 1.0.11)
clipboard-rails (1.7.1)
cliver (0.3.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand Down Expand Up @@ -553,10 +554,6 @@ GEM
peek
sidekiq
pg (0.21.0)
poltergeist (1.15.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
posix-spawn (0.3.13)
power_converter (0.1.2)
powerpack (0.1.1)
Expand Down Expand Up @@ -733,6 +730,9 @@ GEM
useragent
select2-rails (3.5.10)
thor (~> 0.14)
selenium-webdriver (3.4.2)
childprocess (~> 0.5)
rubyzip (~> 1.0)
sidekiq (5.0.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
Expand Down Expand Up @@ -881,7 +881,6 @@ DEPENDENCIES
peek-redis
peek-sidekiq
pg
poltergeist
puma (~> 3.7)
rails (~> 5.1.1)
rails-controller-testing
Expand All @@ -895,6 +894,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
scss_lint
secure_headers
selenium-webdriver
sidekiq
simplecov
solr_wrapper (~> 1.0)
Expand Down
31 changes: 14 additions & 17 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require 'spec_helper'
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/poltergeist'
require 'database_cleaner'
require 'active_fedora/cleaner'

Expand Down Expand Up @@ -54,22 +53,20 @@

# Uses faster rack_test driver when JavaScript support not needed
Capybara.default_driver = :rack_test
Capybara.javascript_driver = :poltergeist

# Adding the below to deal with random Capybara-related timeouts in CI.
# Found in this thread: https://github.com/teampoltergeist/poltergeist/issues/375
poltergeist_options = {
js_errors: false,
timeout: 30,
logger: nil,
phantomjs_logger: StringIO.new,
phantomjs_options: [
'--load-images=no',
'--ignore-ssl-errors=yes'
]
}
Capybara.register_driver(:poltergeist) do |app|
Capybara::Poltergeist::Driver.new(app, poltergeist_options)
Capybara.javascript_driver = :headless_chromium

Capybara.register_driver :headless_chromium do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => {
# 'binary' => "/chromium-latest-linux/466395/chrome-linux/chrome",
'args' => %w(headless no-sandbox disable-gpu)
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: caps
)
end

RSpec.configure do |config|
Expand Down

0 comments on commit aa67444

Please sign in to comment.