aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators_test.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-14 12:34:38 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-14 12:34:38 -0300
commit48c1e6d584409d774b184e0f4d2ef28e5b0e9c90 (patch)
treea2becf0cce37a47579e848780b02f420d335ccd9 /railties/test/generators_test.rb
parent9ac01fad193b27e517ea772e0d1e13e06f4ddf34 (diff)
parentc6bc8e662614be711f45a8d4b231d5f993b024a7 (diff)
downloadrails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.tar.gz
rails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.tar.bz2
rails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.zip
Merge commit 'rails/master'
Diffstat (limited to 'railties/test/generators_test.rb')
-rw-r--r--railties/test/generators_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb
index 89d52dd170..4cc0b33521 100644
--- a/railties/test/generators_test.rb
+++ b/railties/test/generators_test.rb
@@ -4,6 +4,11 @@ require 'generators/test_unit/model/model_generator'
require 'mocha'
class GeneratorsTest < GeneratorsTestCase
+ def setup
+ Rails::Generators.instance_variable_set(:@load_paths, nil)
+ Gem.stubs(:respond_to?).with(:loaded_specs).returns(false)
+ end
+
def test_invoke_when_generator_is_not_found
output = capture(:stdout){ Rails::Generators.invoke :unknown }
assert_equal "Could not find generator unknown.\n", output
@@ -70,6 +75,20 @@ class GeneratorsTest < GeneratorsTestCase
assert_equal "mspec", klass.namespace
end
+ def test_find_by_namespace_lookup_with_gem_specification
+ assert_nil Rails::Generators.find_by_namespace(:xspec)
+ Rails::Generators.instance_variable_set(:@load_paths, nil)
+
+ spec = Gem::Specification.new
+ spec.expects(:full_gem_path).returns(File.join(RAILS_ROOT, 'vendor', 'another_gem_path', 'xspec'))
+ Gem.expects(:respond_to?).with(:loaded_specs).returns(true)
+ Gem.expects(:loaded_specs).returns(:spec => spec)
+
+ klass = Rails::Generators.find_by_namespace(:xspec)
+ assert klass
+ assert_equal "xspec", klass.namespace
+ end
+
def test_builtin_generators
assert Rails::Generators.builtin.include? %w(rails model)
end