From 31c6ea5bc364ae1b5df52d2556131a3ad91c14fc Mon Sep 17 00:00:00 2001 From: rohit Date: Sun, 19 Sep 2010 13:09:42 +0530 Subject: [PATCH] Send 'rails runner' help message to stdout instead of stderr. --- railties/lib/rails/commands/runner.rb | 2 +- railties/test/application/runner_test.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 8100186..1a91d47 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -17,7 +17,7 @@ ARGV.clone.options do |opts| opts.separator "" opts.on("-h", "--help", - "Show this help message.") { $stderr.puts opts; exit } + "Show this help message.") { $stdout.puts opts; exit } if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ opts.separator "" diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 7e99ff6..f9b05f6 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -1,4 +1,5 @@ require 'isolation/abstract_unit' +require 'active_support/core_ext/kernel/reporting' module ApplicationTests class RunnerTest < Test::Unit::TestCase @@ -19,8 +20,10 @@ module ApplicationTests 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` } + help_output = Dir.chdir(app_path) do + silence_stream(STDOUT) { `bundle exec rails runner --help` } + end + assert_match "/rails runner", help_output end def test_should_run_ruby_statement -- 1.7.2.3