Skip to content
Browse files

Make sure that generator's default banner is showing its namespace

This will make `rails g rspec:install --help` shows "rails generate rspec:install [options]" and not "rails generate install  [options]"
  • Loading branch information...
1 parent 5c7fd87 commit fd1daf9a8e751aaa700a18d6ac9c48b6f016ea7c @sikachu sikachu committed with tenderlove Dec 31, 2010
Showing with 11 additions and 1 deletion.
  1. +1 −1 railties/lib/rails/generators/base.rb
  2. +10 −0 railties/test/generators_test.rb
View
2 railties/lib/rails/generators/base.rb
@@ -274,7 +274,7 @@ def class_collisions(*class_names) #:nodoc:
# Use Rails default banner.
#
def self.banner
- "rails generate #{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
+ "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]".gsub(/\s+/, ' ')
end
# Sets the base_name taking into account the current class namespace.
View
10 railties/test/generators_test.rb
@@ -120,6 +120,16 @@ def test_rails_generators_does_not_show_active_record_hooks
assert_match /^ active_record:fixjour$/, output
end
+ def test_default_banner_should_show_generator_namespace
+ klass = Rails::Generators.find_by_namespace(:foobar)
+ assert_match /^rails generate foobar:foobar/, klass.banner
+ end
+
+ def test_default_banner_should_not_show_rails_generator_namespace
+ klass = Rails::Generators.find_by_namespace(:model)
+ assert_match /^rails generate model/, klass.banner
+ end
+
def test_no_color_sets_proper_shell
Rails::Generators.no_color!
assert_equal Thor::Shell::Basic, Thor::Base.shell

0 comments on commit fd1daf9

Please sign in to comment.
Something went wrong with that request. Please try again.