Skip to content
This repository
Browse code

Allow generators nested in more than one level

  • Loading branch information...
commit 20897a6c2cef9c70b97eee1bcd2ed5b78303a274 1 parent c76c699
Santiago Pastorino spastorino authored
2  railties/lib/rails/generators.rb
@@ -155,7 +155,7 @@ def self.find_by_namespace(name, base=nil, context=nil) #:nodoc:
155 155 # commands.
156 156 def self.invoke(namespace, args=ARGV, config={})
157 157 names = namespace.to_s.split(':')
158   - if klass = find_by_namespace(names.pop, names.shift)
  158 + if klass = find_by_namespace(names.pop, names.any? && names.join(':'))
159 159 args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
160 160 klass.start(args, config)
161 161 else
8 railties/test/generators_test.rb
@@ -94,6 +94,14 @@ def test_find_by_namespace_show_warning_if_generator_cant_be_loaded
94 94 assert_match /Rails 2\.x generator/, output
95 95 end
96 96
  97 + def test_invoke_with_nested_namespaces
  98 + model_generator = mock('ModelGenerator') do
  99 + expects(:start).with(["Account"], {})
  100 + end
  101 + Rails::Generators.expects(:find_by_namespace).with('namespace', 'my:awesome').returns(model_generator)
  102 + Rails::Generators.invoke 'my:awesome:namespace', ["Account"]
  103 + end
  104 +
97 105 def test_rails_generators_help_with_builtin_information
98 106 output = capture(:stdout){ Rails::Generators.help }
99 107 assert_match /Rails:/, output

0 comments on commit 20897a6

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