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 91e0d37
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
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 91e0d37

Please sign in to comment.