-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure Capybara to use rack_test driver by default in system specs
- Loading branch information
1 parent
9f6cac1
commit a485bee
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |