mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow generators nested in more than one level
This commit is contained in:
parent
c76c699f30
commit
20897a6c2c
2 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue