Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Capybara to use rack_test driver by default in system specs #51

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'capybara/rspec'

# Use different Capybara ports when running tests in parallel
if ENV['TEST_ENV_NUMBER']
Capybara.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i
end

Capybara.register_driver :chrome_headless do |app|
options = Selenium::WebDriver::Chrome::Options.new

options.add_argument('--headless') unless ENV['HEADLESS'] == 'false'
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument('--window-size=1400,1400')

Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end

Capybara.javascript_driver = :chrome_headless

RSpec.configure do |config|
config.before(:each, type: :system) do
if self.class.metadata[:js] == true
driven_by(:chrome_headless)
else
driven_by(:rack_test)
end
end
end