2024-01-10 23:54:11 +09:00
|
|
|
# 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'
|
|
|
|
|
2024-08-15 15:45:00 +09:00
|
|
|
def common_chrome_options
|
|
|
|
options = Selenium::WebDriver::Chrome::Options.new
|
|
|
|
options.add_argument '--window-size=1680,1050'
|
|
|
|
options.add_argument '--disable-search-engine-choice-screen'
|
|
|
|
options
|
|
|
|
end
|
|
|
|
|
2024-01-10 23:54:11 +09:00
|
|
|
Capybara.register_driver :chrome do |app|
|
2024-08-15 15:45:00 +09:00
|
|
|
Capybara::Selenium::Driver.new(app, browser: :chrome, options: common_chrome_options)
|
2024-01-10 23:54:11 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
Capybara.register_driver :headless_chrome do |app|
|
2024-08-15 15:45:00 +09:00
|
|
|
options = common_chrome_options
|
2024-01-10 23:54:11 +09:00
|
|
|
options.add_argument '--headless=new'
|
|
|
|
|
|
|
|
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
|
2024-05-10 21:36:09 +09:00
|
|
|
driven_by :rack_test
|
|
|
|
end
|
|
|
|
|
|
|
|
config.before(:each, :js, type: :system) do
|
2024-01-10 23:54:11 +09:00
|
|
|
driven_by Capybara.javascript_driver
|
|
|
|
end
|
|
|
|
end
|