diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-07-16 00:52:47 -0700 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-07-16 00:52:47 -0700 |
commit | c612638a257be6cea631a1e5075f671ca328b8dc (patch) | |
tree | 2f4c94ce9b995c1762017ad49a85853589da1808 /railties/lib/rails/generators/test_unit | |
parent | 8df284a0e9fd075a7e77cbb578532950148d0f24 (diff) | |
parent | 5ecd125a62da693320da8ea7bbccd60b71f67e63 (diff) | |
download | rails-c612638a257be6cea631a1e5075f671ca328b8dc.tar.gz rails-c612638a257be6cea631a1e5075f671ca328b8dc.tar.bz2 rails-c612638a257be6cea631a1e5075f671ca328b8dc.zip |
Merge pull request #11419 from simi/generator_generator_test
Added generated unit test for generator generator.
Diffstat (limited to 'railties/lib/rails/generators/test_unit')
-rw-r--r-- | railties/lib/rails/generators/test_unit/generator/generator_generator.rb | 26 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb | 16 |
2 files changed, 42 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/test_unit/generator/generator_generator.rb b/railties/lib/rails/generators/test_unit/generator/generator_generator.rb new file mode 100644 index 0000000000..d7307398ce --- /dev/null +++ b/railties/lib/rails/generators/test_unit/generator/generator_generator.rb @@ -0,0 +1,26 @@ +require 'rails/generators/test_unit' + +module TestUnit # :nodoc: + module Generators # :nodoc: + class GeneratorGenerator < Base # :nodoc: + check_class_collision suffix: "GeneratorTest" + + class_option :namespace, type: :boolean, default: true, + desc: "Namespace generator under lib/generators/name" + + def create_generator_files + template 'generator_test.rb', File.join('test/lib/generators', class_path, "#{file_name}_generator_test.rb") + end + + protected + + def generator_path + if options[:namespace] + File.join("generators", regular_class_path, file_name, "#{file_name}_generator") + else + File.join("generators", regular_class_path, "#{file_name}_generator") + end + end + end + end +end diff --git a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb new file mode 100644 index 0000000000..a7f1fc4fba --- /dev/null +++ b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' +require '<%= generator_path %>' + +<% module_namespacing do -%> +class <%= class_name %>GeneratorTest < Rails::Generators::TestCase + tests <%= class_name %>Generator + destination Rails.root.join('tmp/generators') + setup :prepare_destination + + # test "generator runs without errors" do + # assert_nothing_raised do + # run_generator ["arguments"] + # end + # end +end +<% end -%> |