mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow to generate namespaced generators [#6140 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
f05238e1d2
commit
7891de8939
2 changed files with 41 additions and 2 deletions
|
@ -14,9 +14,9 @@ module Rails
|
||||||
|
|
||||||
def generator_dir
|
def generator_dir
|
||||||
if options[:namespace]
|
if options[:namespace]
|
||||||
File.join("lib", "generators", file_name)
|
File.join("lib", "generators", regular_class_path, file_name)
|
||||||
else
|
else
|
||||||
File.join("lib", "generators")
|
File.join("lib", "generators", regular_class_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,43 @@ class GeneratorGeneratorTest < Rails::Generators::TestCase
|
||||||
assert_file "lib/generators/awesome/awesome_generator.rb",
|
assert_file "lib/generators/awesome/awesome_generator.rb",
|
||||||
/class AwesomeGenerator < Rails::Generators::NamedBase/
|
/class AwesomeGenerator < Rails::Generators::NamedBase/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_namespaced_generator_skeleton
|
||||||
|
run_generator ["rails/awesome"]
|
||||||
|
|
||||||
|
%w(
|
||||||
|
lib/generators/rails/awesome
|
||||||
|
lib/generators/rails/awesome/USAGE
|
||||||
|
lib/generators/rails/awesome/templates
|
||||||
|
).each{ |path| assert_file path }
|
||||||
|
|
||||||
|
assert_file "lib/generators/rails/awesome/awesome_generator.rb",
|
||||||
|
/class Rails::AwesomeGenerator < Rails::Generators::NamedBase/
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generator_skeleton_is_created_without_file_name_namespace
|
||||||
|
run_generator ["awesome", "--namespace", "false"]
|
||||||
|
|
||||||
|
%w(
|
||||||
|
lib/generators/
|
||||||
|
lib/generators/USAGE
|
||||||
|
lib/generators/templates
|
||||||
|
).each{ |path| assert_file path }
|
||||||
|
|
||||||
|
assert_file "lib/generators/awesome_generator.rb",
|
||||||
|
/class AwesomeGenerator < Rails::Generators::NamedBase/
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_namespaced_generator_skeleton_without_file_name_namespace
|
||||||
|
run_generator ["rails/awesome", "--namespace", "false"]
|
||||||
|
|
||||||
|
%w(
|
||||||
|
lib/generators/rails
|
||||||
|
lib/generators/rails/USAGE
|
||||||
|
lib/generators/rails/templates
|
||||||
|
).each{ |path| assert_file path }
|
||||||
|
|
||||||
|
assert_file "lib/generators/rails/awesome_generator.rb",
|
||||||
|
/class Rails::AwesomeGenerator < Rails::Generators::NamedBase/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue