Skip to content

Commit

Permalink
warn user if options are given before application name [#3435 state:r…
Browse files Browse the repository at this point in the history
…esolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
ravinderrana authored and josevalim committed Apr 29, 2010
1 parent d793d30 commit e9a9ef0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Expand Up @@ -55,6 +55,7 @@ class AppGenerator < Base
:desc => "Show this help message and quit" :desc => "Show this help message and quit"


def initialize(*args) def initialize(*args)
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
super super
if !options[:skip_activerecord] && !DATABASES.include?(options[:database]) if !options[:skip_activerecord] && !DATABASES.include?(options[:database])
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}." raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
Expand Down
5 changes: 5 additions & 0 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -58,6 +58,11 @@ def test_application_controller_and_layout_files
assert_no_file "public/stylesheets/application.css" assert_no_file "public/stylesheets/application.css"
end 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 def test_name_collision_raises_an_error
content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] } 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 assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content
Expand Down

0 comments on commit e9a9ef0

Please sign in to comment.