diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 783258b3af..aabb121fc3 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -108,8 +108,6 @@ RSpec.configure do |config| end config.around :each, type: :system do |example| - driven_by :selenium, using: :headless_chrome, screen_size: [1600, 1200] - # The streaming server needs access to the database # but with use_transactional_tests every transaction # is rolled-back, so the streaming server never sees the data diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb new file mode 100644 index 0000000000..d4f27e209e --- /dev/null +++ b/spec/support/capybara.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +Capybara.server_host = 'localhost' +Capybara.server_port = 3000 +Capybara.app_host = "http://#{Capybara.server_host}:#{Capybara.server_port}" + +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.add_argument '--headless=new' + options.add_argument '--window-size=1680,1050' + + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + options: options + ) +end + +Capybara.javascript_driver = :headless_chrome + +RSpec.configure do |config| + config.before(:each, type: :system) do + driven_by Capybara.javascript_driver + end +end