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 Mar 27, 2018
1 parent 116d4b9 commit 3b8b867
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
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:
- SPEC=spec/features/create_image_spec.rb
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- AWS_REGION=us-east-1
- secure: BnmjWPatxrNOpYKw05B54q+CUiDRw16bnL0YMvBU6XDotOTNnGjG24oul3et0wmOx0TfgLXLQ3twyWnOkW5HEIUGzjX825Pd/Ur8YaHZI9KeQc9FrAn43aDIVAtbnkg7lxMqsJZUmfSHzUXkbyPmMtLc+LK9wteQ0kdzIplsenyLV7VRTP8jINxkUnt/TYj5poah1RU9NemvGcUKW2hC3aW0d8/yjAV7boZodgBSiMSHSLQvScNNvS3+Goymlq15hl26ZjMqddLMJgRZwskZhDyAgUQuZpSHymXlzRSiSzSshJW1ST0MLmECImRdJ6t/JP2cf0ZHN/sR2XBG0ABc9dQfKB/aLITbZ5IbSHyjOoBzlilSixNVT7+VoW6MfbnXFlg2cwFfKgKPkXElADcIUT7lRcTiR5EO7oJILJ8C1psOFtC1XtbKVT1P4zHXoFqvaNQ8iWg0sMdSbYfDxfG9ObAA0SYA4d7ZvbZ0bt8XUhWFsBoMEAi6bzDxsp4jPkKIAjboDar/iol/rEIF2FwaRIjoTsM+MzN+p+P1bqjMFIJsFRX7DqzJ/6XP+vm+z437oEWKbTGnPlCWCwBw2qOpQNwe9o5wzP2H3KN2u0AcVs2UUcyE/pPObvWFKiGXC5FAljdyjv1jjHmuvBnnsuAkB3siqbEpvT7S/c4Qi8L8/To=
- secure: FknMcFAQQAZMZZeUOgm1pyYI7s2/I+JYpKzCDI4y7MjwdGjRWs1vM1suud2sEtBEtCajeedvXDhrENHPEwVaBwKwgOkQxb6WjcVHLm9MBzrG5apWOZre9hAdbZXcs5QVpoA/xj3ASLF/XV4wndyN03eex0cAYRekh/rTsHPhItdEOc1PuZKuLb+3UNWKp9tyQ1oHA7ZqeEvyEK6EqOMBBW9EBdnkYN6JT5x1NwAtm0FPTia58UQyUdqjSLv7oWUAutACyPCS5zNsBwpzJWaQ2x7qhCDuRB8X0J0lz5lReuBx9j2FW0dWLEdj11gam0osdYux85Tk5fPOOGtKRmNwWFqSPrvzIvcuR/C3pzlfr35d+KduK+OD3EnsKL2Cp6mkgQPlBDGvKGl6GH0aiOenhHxjNIsG5eK29Gyit0EQRLosHy+eDZymzvT97WNheali+PKTFmopatmFILmID2Gnk66yvtdeNFFBUCAMVH3t0C/8hsSt484HP1AiwaPR4aeucMOJmK+H7xvwQRPs+vYemGYL7bBRoQE7F6tr9UQFMyw7/WuKPNSx1KV8bhcmoCOrOpjxzVvMjhokX83CGxok2hA/vhhHMHjh3D+Z+uhJzLja/gDJAa5rPHkqQMUdUssJ0/R9IiW+tEGHdUM8hPrzyFU5V1DmcO1DEBFvSeTvL/4=

cache:
bundler: true
directories:
- "travis_phantomjs"

jdk:
- oraclejdk8
addons:
chrome: stable
hosts:
- tenant1.localhost
- tenant2.localhost
Expand All @@ -30,12 +29,7 @@ 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"
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &

before_script:
- bundle exec rake db:create
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ end

group :test do
gem 'capybara'
gem 'chromedriver-helper'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'poltergeist'
gem 'rails-controller-testing'
gem 'selenium-webdriver'
gem 'webmock'
end

Expand Down
21 changes: 14 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ GEM
apartment (1.2.0)
activerecord (>= 3.1.2, < 6.0)
rack (>= 1.3.6)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (8.0.0)
ast (2.3.0)
atomic (1.1.99)
Expand Down Expand Up @@ -149,8 +151,12 @@ 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)
chromedriver-helper (1.2.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
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 @@ -407,6 +413,7 @@ GEM
activesupport (>= 4)
iiif-presentation (~> 0.2.0)
inflecto (0.0.2)
io-like (0.3.0)
is_it_working (1.1.0)
iso-639 (0.2.8)
jbuilder (2.7.0)
Expand Down Expand Up @@ -587,10 +594,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 @@ -770,6 +773,9 @@ GEM
useragent
select2-rails (3.5.10)
thor (~> 0.14)
selenium-webdriver (3.4.2)
childprocess (~> 0.5)
rubyzip (~> 1.0)
shex (0.5.1)
ebnf (~> 1.1)
json-ld (~> 2.1)
Expand Down Expand Up @@ -900,6 +906,7 @@ DEPENDENCIES
byebug
capybara
carrierwave-aws
chromedriver-helper
coffee-rails (~> 4.2)
config (~> 1.5, >= 1.5.1)
coveralls
Expand Down Expand Up @@ -930,7 +937,6 @@ DEPENDENCIES
peek-redis
peek-sidekiq
pg
poltergeist
puma (~> 3.7)
rails (~> 5.1.1)
rails-controller-testing
Expand All @@ -944,6 +950,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
scss_lint
secure_headers
selenium-webdriver
sidekiq
simplecov
solr_wrapper (~> 1.0)
Expand All @@ -956,4 +963,4 @@ DEPENDENCIES
zk

BUNDLED WITH
1.16.0
1.16.1
30 changes: 13 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,23 +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.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

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
Expand Down

0 comments on commit 3b8b867

Please sign in to comment.