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

Use headless driver for next Rails release #2746

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ def initialize(*args, &blk)
self.class.before do
# A user may have already set the driver, so only default if driver
# is not set
driven_by(:selenium) unless @driver
if ::Rails::VERSION::STRING.to_f >= 7.2
driven_by(:selenium_chrome_headless) unless @driver
else
driven_by(:selenium) unless @driver
end
end
end

Expand Down
12 changes: 11 additions & 1 deletion spec/rspec/rails/example/system_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module RSpec::Rails
end

describe '#driver' do
it 'uses :selenium driver by default' do
it 'uses :selenium driver by default', if: ::Rails::VERSION::STRING.to_f < 7.2 do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup
end
Expand All @@ -40,6 +40,16 @@ module RSpec::Rails
expect(Capybara.current_driver).to eq :selenium
end

it 'uses :selenium_chrome_headless driver by default', if: ::Rails::VERSION::STRING.to_f >= 7.2 do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup
end
example = group.new
group.hooks.run(:before, :example, example)

expect(Capybara.current_driver).to eq :selenium_chrome_headless
end

it 'sets :rack_test driver using by before_action' do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup
Expand Down