Skip to content

Commit 30506d2

Browse files
Devcontainers: Introduce SystemTestCase#served_by
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 <[email protected]>
1 parent 48fac06 commit 30506d2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

actionpack/lib/action_dispatch/system_test_case.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {
161161
self.driver = SystemTesting::Driver.new(driver, **driver_options, &capabilities)
162162
end
163163

164+
# Configuration for the System Test application server
165+
#
166+
# By default this is localhost. This method allows the host and port to be specified manually.
167+
def self.served_by(host:, port:)
168+
Capybara.server_host = host
169+
Capybara.server_port = port
170+
end
171+
164172
private
165173
def url_helpers
166174
@url_helpers ||=

railties/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
* Introduce `SystemTestCase#served_by` for configuring the System Test application server
2+
3+
By default this is localhost. This method allows the host and port to be specified manually.
4+
5+
```ruby
6+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
7+
served_by host: "testserver", port: 45678
8+
end
9+
```
10+
11+
*Andrew Novoselac & Rafael Mendonça França*
12+
113
* `bin/rails test` will no longer load files named `*_test.rb` if they are located in the `fixtures` folder.
214

315
*Edouard Chin*

0 commit comments

Comments
 (0)