Skip to content

Commit d20b682

Browse files
authored
Merge pull request rails#52555 from rails/rm-fix-system-test
Fix indentation of the application_system_test_case with devcontainer
2 parents 9d241e6 + f159f91 commit d20b682

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

railties/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def update_application_system_test_case
4040
return unless options[:system_test]
4141
return unless File.exist?("test/application_system_test_case.rb")
4242

43-
gsub_file("test/application_system_test_case.rb", /^(\s*driven_by\b.*)/, system_test_configuration)
43+
gsub_file("test/application_system_test_case.rb", /^\s*driven_by\b.*/, system_test_configuration)
4444
end
4545

4646
def update_database_yml
@@ -148,17 +148,17 @@ def local_rails_mount
148148
end
149149

150150
def system_test_configuration
151-
<<~'RUBY'
152-
if ENV["CAPYBARA_SERVER_PORT"]
153-
served_by host: "rails-app", port: ENV["CAPYBARA_SERVER_PORT"]
154-
155-
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
156-
browser: :remote,
157-
url: "http://#{ENV["SELENIUM_HOST"]}:4444"
158-
}
159-
else
160-
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
161-
end
151+
optimize_indentation(<<-'RUBY', 2)
152+
if ENV["CAPYBARA_SERVER_PORT"]
153+
served_by host: "rails-app", port: ENV["CAPYBARA_SERVER_PORT"]
154+
155+
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
156+
browser: :remote,
157+
url: "http://#{ENV["SELENIUM_HOST"]}:4444"
158+
}
159+
else
160+
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
161+
end
162162
RUBY
163163
end
164164
end

railties/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ services:
2626
<%- if options[:system_test] -%>
2727

2828
selenium:
29-
image: seleniarm/standalone-chromium
29+
image: selenium/standalone-chromium
3030
restart: unless-stopped
3131
<%- end -%>
3232

railties/test/fixtures/.devcontainer/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
- redis
2121

2222
selenium:
23-
image: seleniarm/standalone-chromium
23+
image: selenium/standalone-chromium
2424
restart: unless-stopped
2525

2626
redis:

railties/test/generators/app_generator_test.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,10 @@ def test_devcontainer
12371237
assert_match(/ARG RUBY_VERSION=#{RUBY_VERSION}/, content)
12381238
end
12391239
assert_file("test/application_system_test_case.rb") do |content|
1240-
assert_match(/served_by host: "rails-app", port: ENV\["CAPYBARA_SERVER_PORT"\]/, content)
1240+
assert_match(/^ served_by host: "rails-app", port: ENV\["CAPYBARA_SERVER_PORT"\]/, content)
1241+
assert_match(/^ driven_by :selenium, using: :headless_chrome, screen_size: \[ 1400, 1400 \], options: {$/, content)
1242+
assert_match(/^ browser: :remote,$/, content)
1243+
assert_match(/^ url: "http:\/\/\#{ENV\["SELENIUM_HOST"\]}:4444"$/, content)
12411244
end
12421245
assert_compose_file do |compose_config|
12431246
assert_equal "my_app", compose_config["name"]
@@ -1255,7 +1258,7 @@ def test_devcontainer
12551258
assert_equal expected_rails_app_config, compose_config["services"]["rails-app"]
12561259

12571260
expected_selenium_conifg = {
1258-
"image" => "seleniarm/standalone-chromium",
1261+
"image" => "selenium/standalone-chromium",
12591262
"restart" => "unless-stopped",
12601263
}
12611264

0 commit comments

Comments
 (0)