-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
What Ruby, Rails and RSpec versions are you using?
ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [aarch64-linux]
Rails 8.0.2
RSpec 3.13
- rspec-core 3.13.3
- rspec-expectations 3.13.3
- rspec-mocks 3.13.2
- rspec-rails 7.1.1
- rspec-support 3.13.2
Observed behaviour
https://api.rubyonrails.org/v8.0.2/classes/ActionDispatch/SystemTestCase.html
has a public helper method served_by introduced by
rails/rails@30506d2
This is used in the rails new devcontainer template for application_system_test_case.rb
https://github.com/rails/rails/blob/621aa49cefce3313fbc672e2f3681103da686a0e/railties/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb#L163
If I use similar configuration within my rspec rails_helper.rb
config.before(:each, type: :system, js: true) do
if ENV['CAPYBARA_SERVER_PORT']
served_by host: 'rails-app', port: ENV['CAPYBARA_SERVER_PORT']
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400], options: {
browser: :remote,
url: "http://#{ENV['SELENIUM_HOST']}:4444"
}
else
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
end
end
when I run rspec, I see a failure.
NoMethodError:
undefined method 'served_by' for #<RSpec::ExampleGroups::MyExample:0x0000ffff74d3d398>
Expected behaviour
I would expect this method to be supported.
Proposed fix
An addition to lib/rspec/rails/example/system_example_group.rb of a method to pass through the call will allow this same config to pass.
def served_by(**options)
::ActionDispatch::SystemTestCase.served_by(**options)
end