diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f8f2152514..4c32fa8991 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -6,7 +6,6 @@ require "rspec/rails" require "shoulda/matchers" -require "selenium/webdriver" Dir[Rails.root.join("../../spec/support/**/*.rb")].each { |file| require file } @@ -31,22 +30,3 @@ module Features end ActiveRecord::Migration.maintain_test_schema! - -Capybara.register_driver :chrome do |app| - Capybara::Selenium::Driver.new(app, browser: :chrome) -end - -Capybara.register_driver :headless_chrome do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { - args: %w[headless enable-features=NetworkService,NetworkServiceInProcess] - } - ) - Capybara::Selenium::Driver.new app, - browser: :chrome, - desired_capabilities: capabilities -end - -Capybara.javascript_driver = :selenium_chrome_headless - -Capybara.server = :webrick diff --git a/spec/support/webdrivers.rb b/spec/support/webdrivers.rb new file mode 100644 index 0000000000..80510abfaa --- /dev/null +++ b/spec/support/webdrivers.rb @@ -0,0 +1,30 @@ +require "selenium/webdriver" + +Capybara.register_driver :chrome do |app| + Capybara::Selenium::Driver.new(app, browser: :chrome) +end + +Capybara.register_driver :headless_chrome do |app| + options = ::Selenium::WebDriver::Chrome::Options.new + options.headless! + options.add_argument "--window-size=1680,1050" + + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + options: options, + ) +end + +Capybara.javascript_driver = :headless_chrome +Capybara.server = :webrick + +RSpec.configure do |config| + config.before(:each, type: :system) do + driven_by :rack_test + end + + config.before(:each, type: :system, js: true) do + driven_by Capybara.javascript_driver + end +end