提交 20897a6c 编写于 作者: S Santiago Pastorino

Allow generators nested in more than one level

上级 c76c699f
......@@ -155,7 +155,7 @@ def self.find_by_namespace(name, base=nil, context=nil) #:nodoc:
# 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
......
......@@ -94,6 +94,14 @@ def test_find_by_namespace_show_warning_if_generator_cant_be_loaded
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册