aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRobert Thau <rst@smartleaf.com>2017-03-21 23:07:07 -0400
committerRobert Thau <rst@smartleaf.com>2017-03-22 12:04:19 -0400
commita06a643e0572b8c983738c068ae637d020188c97 (patch)
tree2f72d566f55050dba816468e1c92f5d691d20cf6 /railties/test
parent34fe2a4fc778d18b7fe6bdf3629c1481bee789b9 (diff)
downloadrails-a06a643e0572b8c983738c068ae637d020188c97.tar.gz
rails-a06a643e0572b8c983738c068ae637d020188c97.tar.bz2
rails-a06a643e0572b8c983738c068ae637d020188c97.zip
Correctly reset ARGV for "rails runner `CODE' arg arg arg..."
The code itself should not be in the ARGV vector. Fixes #28515
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/runner_test.rb8
1 files changed, 8 insertions, 0 deletions
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