1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix output of 'rails runner --help' [#4249 state:open]

This commit is contained in:
rohit 2010-09-16 09:32:33 +05:30 committed by José Valim
parent 37de59eacf
commit 76266a8184
2 changed files with 6 additions and 1 deletions

View file

@ -23,7 +23,7 @@ ARGV.clone.options do |opts|
opts.separator "" opts.separator ""
opts.separator "You can also use runner as a shebang line for your scripts like this:" opts.separator "You can also use runner as a shebang line for your scripts like this:"
opts.separator "-------------------------------------------------------------" 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 ""
opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }" opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }"
opts.separator "-------------------------------------------------------------" opts.separator "-------------------------------------------------------------"

View file

@ -18,6 +18,11 @@ module ApplicationTests
MODEL MODEL
end 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 def test_should_run_ruby_statement
assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "puts User.count"` } assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "puts User.count"` }
end end