Skip to content

Commit

Permalink
Devcontainers: Introduce SystemTestCase#served_by
Browse files Browse the repository at this point in the history
When working in a devcontainer, for system tests we need to manually set the host and port serving the application. Let's introduce a method for this, so we don't have to expose the implementation details of Capybara to the developer.

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
  • Loading branch information
andrewn617 and rafaelfranca committed Feb 14, 2024
1 parent 0820244 commit d2d42de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions actionpack/lib/action_dispatch/system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {
self.driver = SystemTesting::Driver.new(driver, **driver_options, &capabilities)
end

# Configuration for the System Test application server
#
# By default this is localhost. This method allows the host and port to be specified manually.
def self.served_by(host:, port:)
Capybara.server_host = host
Capybara.server_port = port
end

private
def url_helpers
@url_helpers ||=
Expand Down
12 changes: 12 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
* Introduce `SystemTestCase#served_by` for configuring the System Test application server

By default this is localhost. This method allows the host and port to be specified manually.

```ruby
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
served_by host: "testserver", port: 45678
end
```

*Andrew Novoselac & Rafael Mendonça França*

* Use `ruby file: ".ruby-version"` in generated Gemfile if supported.

*Hartley McGuire*
Expand Down

0 comments on commit d2d42de

Please sign in to comment.