From e15b5eda2b4888764cd0c63a297136babac026d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 3 Nov 2009 20:50:39 -0200 Subject: Avoid duplicated names on help description and show proper error message if trying to load a Rails 2.x generator. Signed-off-by: Jeremy Kemper --- .../test/fixtures/lib/generators/foobar/foobar_generator.rb | 4 ++++ railties/test/generators_test.rb | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 railties/test/fixtures/lib/generators/foobar/foobar_generator.rb (limited to 'railties/test') diff --git a/railties/test/fixtures/lib/generators/foobar/foobar_generator.rb b/railties/test/fixtures/lib/generators/foobar/foobar_generator.rb new file mode 100644 index 0000000000..d1de8c56fa --- /dev/null +++ b/railties/test/fixtures/lib/generators/foobar/foobar_generator.rb @@ -0,0 +1,4 @@ +module Foobar + class FoobarGenerator < Rails::Generators::Base + end +end diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 8f1984c7d2..07f51eca01 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -45,6 +45,12 @@ class GeneratorsTest < GeneratorsTestCase assert_equal "test_unit:generators:model", klass.namespace end + def test_find_by_namespace_with_duplicated_name + klass = Rails::Generators.find_by_namespace(:foobar) + assert klass + assert_equal "foobar:foobar", klass.namespace + end + def test_find_by_namespace_add_generators_to_raw_lookups klass = Rails::Generators.find_by_namespace("test_unit:model") assert klass @@ -101,14 +107,15 @@ class GeneratorsTest < GeneratorsTestCase def test_rails_generators_with_others_information output = capture(:stdout){ Rails::Generators.help }.split("\n").last - assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts.", output + assert_equal "Others: active_record:fixjour, fixjour, foobar, mspec, rails:javascripts.", output end def test_warning_is_shown_if_generator_cant_be_loaded Rails::Generators.load_paths << File.join(Rails.root, "vendor", "gems", "gems", "wrong") output = capture(:stderr){ Rails::Generators.find_by_namespace(:wrong) } + assert_match /\[WARNING\] Could not load generator at/, output - assert_match /Error: uninitialized constant Rails::Generator/, output + assert_match /Rails 2\.x generator/, output end def test_no_color_sets_proper_shell -- cgit v1.2.3