Browse files

"rails new -h" shows message in rails directory

  • Loading branch information...
1 parent 4c1dcb0 commit 4bb76eecfef844c33e141dc9e167b9fc281fe83d @alekseykulikov alekseykulikov committed Apr 9, 2012
Showing with 17 additions and 3 deletions.
  1. +7 −3 railties/lib/rails/commands.rb
  2. +10 −0 railties/test/generators/app_generator_test.rb
View
10 railties/lib/rails/commands.rb
@@ -64,9 +64,13 @@
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'
View
10 railties/test/generators/app_generator_test.rb
@@ -83,6 +83,16 @@ def test_application_new_exits_with_message_and_non_zero_code_when_generating_in
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")

0 comments on commit 4bb76ee

Please sign in to comment.