warn user if options are given before application name [#3435 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Ravinder Singh
2010-04-16 16:58:14 +05:30
committed by José Valim
parent d793d30776
commit e9a9ef094e
2 changed files with 6 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ module Rails::Generators
:desc => "Show this help message and quit"
def initialize(*args)
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
super
if !options[:skip_activerecord] && !DATABASES.include?(options[:database])
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."

View File

@@ -58,6 +58,11 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_no_file "public/stylesheets/application.css"
end
def test_options_before_application_name_raises_an_error
content = capture(:stderr){ run_generator(["--skip-activerecord", destination_root]) }
assert_equal "Options should be given after the application name. For details run: rails --help\n", content
end
def test_name_collision_raises_an_error
content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] }
assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content