Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def driven_by(driver, **driver_options, &blk)
@driver = ::ActionDispatch::SystemTestCase.driven_by(driver, **driver_options, &blk).tap(&:use)
end

if ::Rails::VERSION::STRING.to_f >= 7.2
def served_by(**options)
::ActionDispatch::SystemTestCase.served_by(**options)
end
end

before do
@routes = ::Rails.application.routes
end
Expand Down
15 changes: 15 additions & 0 deletions spec/rspec/rails/example/system_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ module RSpec::Rails

expect(example).to have_received(:driven_by).once
end

it 'calls :served_by method only once', if: ::Rails::VERSION::STRING.to_f >= 7.2 do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup

before do
served_by(host: 'rails', port: 8080)
end
end
example = group.new
allow(example).to receive(:served_by).and_call_original
group.hooks.run(:before, :example, example)

expect(example).to have_received(:served_by).once
end
end

describe '#after' do
Expand Down