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 13, 2024
1 parent 020d404 commit dad6511
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*

* Ensure logger tags configured with `config.log_tags` are still active in `request.action_dispatch` handlers

*KJ Tsanaktsidis*
Expand Down

0 comments on commit dad6511

Please sign in to comment.