diff --git a/.travis.yml b/.travis.yml index cae997f..3e81dee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,16 +15,14 @@ - $HOME/.npm addons: - chrome: beta + chrome: stable apt: packages: - nodejs - - google-chrome-stable - - google-chrome-stable - - chromium-chromedriver matrix: fast_finish: true + include: rvm: # Use 2.4.1, since this is installed by default on Travis (1st Aug, 2018) diff --git a/Gemfile b/Gemfile index 554b734..74904ab 100644 --- a/Gemfile +++ b/Gemfile @@ -175,10 +175,10 @@ gem "capybara-screenshot" # The next generation developer focused tool for automated testing of webapps (https://github.com/SeleniumHQ/selenium) - gem 'selenium-webdriver' + gem 'selenium-webdriver', '>= 3.13.1' # Easy installation and use of chromedriver. (https://github.com/flavorjones/chromedriver-helper) - gem 'chromedriver-helper' + gem 'chromedriver-helper', ">= 1.2.0" end group :ci do diff --git a/Gemfile.lock b/Gemfile.lock index 1178958..0a1f14d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -389,7 +389,7 @@ byebug capybara capybara-screenshot - chromedriver-helper + chromedriver-helper (>= 1.2.0) contact_us database_cleaner devise @@ -426,7 +426,7 @@ rubocop rubocop-rspec ruby_dig - selenium-webdriver + selenium-webdriver (>= 3.13.1) shoulda simplecov spring diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 8924835..18d14a9 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -9,6 +9,20 @@ Capybara.default_driver = :rack_test +# This is a customisation of the default :selenium_chrome_headless config in: +# https://github.com/teamcapybara/capybara/blob/master/lib/capybara.rb +# +# This adds the --no-sandbox flag to fix TravisCI as described here: +# https://docs.travis-ci.com/user/chrome#sandboxing +Capybara.register_driver :custom_chrome_headless do |app| + Capybara::Selenium::Driver.load_selenium + browser_options = ::Selenium::WebDriver::Chrome::Options.new + browser_options.args << '--headless' + browser_options.args << '--no-sandbox' + browser_options.args << '--disable-gpu' if Gem.win_platform? + Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) +end + RSpec.configure do |config| config.before(:each, type: :feature, js: false) do @@ -16,7 +30,7 @@ end config.before(:each, type: :feature, js: true) do - Capybara.current_driver = :selenium_chrome_headless + Capybara.current_driver = :custom_chrome_headless Capybara.page.driver.browser.manage.window.size = DIMENSION end