diff options
author | ask <alekseys.kulikov@gmail.com> | 2012-04-09 22:26:52 +0600 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-04-13 16:05:25 +0200 |
commit | 2f9fdbfb9468ff24a9f52763848c75fe72003522 (patch) | |
tree | a3a6ac5dc8b0edd2f1f29e851b649449a062bab2 /railties | |
parent | efa9a1ff8b479b860f2ce7019dd4d50ebc5bf0ef (diff) | |
download | rails-2f9fdbfb9468ff24a9f52763848c75fe72003522.tar.gz rails-2f9fdbfb9468ff24a9f52763848c75fe72003522.tar.bz2 rails-2f9fdbfb9468ff24a9f52763848c75fe72003522.zip |
"rails new -h" shows message in rails directory
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 10 |
2 files changed, 17 insertions, 3 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index ada150ceec..8eee82fdf1 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -64,9 +64,13 @@ when 'application', 'runner' require "rails/commands/#{command}" when 'new' - puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" - puts "Type 'rails' for help." - exit(1) + if ARGV.first.in?(['-h', '--help']) + require 'rails/commands/application' + else + puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" + puts "Type 'rails' for help." + exit(1) + end when '--version', '-v' ARGV.unshift '--version' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index f1e760c52f..0803fd0fc5 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -84,6 +84,16 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_equal false, $?.success? end + def test_application_new_show_help_message_inside_existing_rails_directory + app_root = File.join(destination_root, 'myfirstapp') + run_generator [app_root] + output = Dir.chdir(app_root) do + `rails new --help` + end + assert_match /rails new APP_PATH \[options\]/, output + assert_equal true, $?.success? + end + def test_application_name_is_detected_if_it_exists_and_app_folder_renamed app_root = File.join(destination_root, "myapp") app_moved_root = File.join(destination_root, "myapp_moved") |