1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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]"
This commit is contained in:
Prem Sichanugrist 2010-12-31 23:54:49 +07:00 committed by Aaron Patterson
parent 5c7fd87665
commit fd1daf9a8e
2 changed files with 11 additions and 1 deletions

View file

@ -274,7 +274,7 @@ module Rails
# 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 file

@ -120,6 +120,16 @@ class GeneratorsTest < Rails::Generators::TestCase
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