From a06a643e0572b8c983738c068ae637d020188c97 Mon Sep 17 00:00:00 2001 From: Robert Thau Date: Tue, 21 Mar 2017 23:07:07 -0400 Subject: Correctly reset ARGV for "rails runner `CODE' arg arg arg..." The code itself should not be in the ARGV vector. Fixes #28515 --- railties/test/application/runner_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 7d058f6ee6..e8fac442bd 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -35,6 +35,14 @@ module ApplicationTests assert_match "42", Dir.chdir(app_path) { `bin/rails runner "puts User.count"` } end + def test_should_set_argv_when_running_code + output = Dir.chdir(app_path) { + # Both long and short args, at start and end of ARGV + `bin/rails runner "puts ARGV.join(',')" --foo a1 -b a2 a3 --moo` + } + assert_equal "--foo,a1,-b,a2,a3,--moo", output.chomp + end + def test_should_run_file app_file "bin/count_users.rb", <<-SCRIPT puts User.count -- cgit v1.2.3 From 9bc6178e008714828969dcaf1cfde8f62dc9d41f Mon Sep 17 00:00:00 2001 From: Robert Thau Date: Wed, 22 Mar 2017 12:36:27 -0400 Subject: Fixup trailing whitespace, per complaints from CodeClimate. --- railties/test/application/runner_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index e8fac442bd..0c45bc398a 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -36,7 +36,7 @@ module ApplicationTests end def test_should_set_argv_when_running_code - output = Dir.chdir(app_path) { + output = Dir.chdir(app_path) { # Both long and short args, at start and end of ARGV `bin/rails runner "puts ARGV.join(',')" --foo a1 -b a2 a3 --moo` } -- cgit v1.2.3