From 76266a818449c732440e7e2ef4de8442ac6af891 Mon Sep 17 00:00:00 2001 From: rohit Date: Thu, 16 Sep 2010 09:32:33 +0530 Subject: [PATCH] Fix output of 'rails runner --help' [#4249 state:open] --- railties/lib/rails/commands/runner.rb | 2 +- railties/test/application/runner_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 54a9e6ec59..81001867cf 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -23,7 +23,7 @@ ARGV.clone.options do |opts| opts.separator "" opts.separator "You can also use runner as a shebang line for your scripts like this:" opts.separator "-------------------------------------------------------------" - opts.separator "#!/usr/bin/env #{File.expand_path($0)}" + opts.separator "#!/usr/bin/env #{File.expand_path($0)} runner" opts.separator "" opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }" opts.separator "-------------------------------------------------------------" diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 07a3d94120..7e99ff624d 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -18,6 +18,11 @@ module ApplicationTests MODEL end + def test_should_include_runner_in_shebang_line_in_help + # redirect stderr to stdout as backticks don't capture stderr + assert_match "/rails runner", Dir.chdir(app_path) { `bundle exec rails runner --help 2>&1` } + end + def test_should_run_ruby_statement assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "puts User.count"` } end