aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-01-12 21:27:38 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2011-01-12 21:42:56 -0200
commit20897a6c2cef9c70b97eee1bcd2ed5b78303a274 (patch)
tree11bebfc4067bd2271d10fabbf5b455a980480b31
parentc76c699f301678f86054b1019fa1ca78c46df47b (diff)
downloadrails-20897a6c2cef9c70b97eee1bcd2ed5b78303a274.tar.gz
rails-20897a6c2cef9c70b97eee1bcd2ed5b78303a274.tar.bz2
rails-20897a6c2cef9c70b97eee1bcd2ed5b78303a274.zip
Allow generators nested in more than one level
-rw-r--r--railties/lib/rails/generators.rb2
-rw-r--r--railties/test/generators_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 66c4088a68..29e693dfb0 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -155,7 +155,7 @@ module Rails
# commands.
def self.invoke(namespace, args=ARGV, config={})
names = namespace.to_s.split(':')
- if klass = find_by_namespace(names.pop, names.shift)
+ if klass = find_by_namespace(names.pop, names.any? && names.join(':'))
args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
klass.start(args, config)
else
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb
index 3b3d00b6f1..99c9d790eb 100644
--- a/railties/test/generators_test.rb
+++ b/railties/test/generators_test.rb
@@ -94,6 +94,14 @@ class GeneratorsTest < Rails::Generators::TestCase
assert_match /Rails 2\.x generator/, output
end
+ def test_invoke_with_nested_namespaces
+ model_generator = mock('ModelGenerator') do
+ expects(:start).with(["Account"], {})
+ end
+ Rails::Generators.expects(:find_by_namespace).with('namespace', 'my:awesome').returns(model_generator)
+ Rails::Generators.invoke 'my:awesome:namespace', ["Account"]
+ end
+
def test_rails_generators_help_with_builtin_information
output = capture(:stdout){ Rails::Generators.help }
assert_match /Rails:/, output