diff options
author | Prem Sichanugrist <s@sikachu.com> | 2010-12-31 23:54:49 +0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-01 11:58:09 -0800 |
commit | fd1daf9a8e751aaa700a18d6ac9c48b6f016ea7c (patch) | |
tree | 0e0a57530e2bfbc7cff9cc2b58a50c6179c6713d | |
parent | 5c7fd8766586dba42fba6fc738a733175dd9d46b (diff) | |
download | rails-fd1daf9a8e751aaa700a18d6ac9c48b6f016ea7c.tar.gz rails-fd1daf9a8e751aaa700a18d6ac9c48b6f016ea7c.tar.bz2 rails-fd1daf9a8e751aaa700a18d6ac9c48b6f016ea7c.zip |
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]"
-rw-r--r-- | railties/lib/rails/generators/base.rb | 2 | ||||
-rw-r--r-- | railties/test/generators_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index f97f3db588..131eb6ff6f 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -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. diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 346c9ceb9d..3b3d00b6f1 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -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 |