Files
nairobi/spec/rails_helper.rb
Javi Martín 2c4acb0bf7 Use chromedriver 2.38
The latest stable version is causing problems on some machines, hanging
forever in tests involving frames. So we're installing an old version
which works with the latest Chrome.

Note this means we're using an unsupported version. Officially, only the
latest chromedriver supports the latest Chrome.

We're using 2.38 instead of a more recent one (like 2.40) because it's
the one we specified in our Dockerfile.

See also:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=3361
2020-05-25 15:50:36 +02:00

59 lines
1.5 KiB
Ruby

ENV["RAILS_ENV"] ||= "test"
if ENV["TRAVIS"]
require "coveralls"
Coveralls.wear!("rails")
end
require File.expand_path("../../config/environment", __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
require "spec_helper"
require "capybara/rails"
require "capybara/rspec"
require "selenium/webdriver"
Rails.application.load_tasks if Rake::Task.tasks.empty?
include Warden::Test::Helpers
Warden.test_mode!
ActiveRecord::Migration.maintain_test_schema!
# Monkey patch from https://github.com/rails/rails/pull/32293
# Remove when we upgrade to Rails 5.2
require "action_dispatch/system_testing/test_helpers/setup_and_teardown"
module ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
def after_teardown
take_failed_screenshot
Capybara.reset_sessions!
ensure
super
end
end
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.after do
Warden.test_reset!
end
end
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
"goog:chromeOptions" => {
args: %W[headless no-sandbox window-size=1200,600 proxy-server=127.0.0.1:#{Capybara::Webmock.port_number}]
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities
)
end
Capybara.exact = true
Webdrivers::Chromedriver.required_version = "2.38"
OmniAuth.config.test_mode = true