Permalink
Browse files

determine_constant_from_test_name does not swallow NoMethodErrors [Yv…

…es Senn]
  • Loading branch information...
1 parent 0417bc8 commit 341e61154715c7e0f9f4eee7dd90580202735db7 @fxn fxn committed Mar 28, 2013
@@ -38,6 +38,8 @@ def determine_constant_from_test_name(test_name)
begin
constant = names.join("::").constantize
break(constant) if yield(constant)
+ rescue NoMethodError # subclass of NameError
+ raise
rescue NameError
# Constant wasn't found, move on
ensure
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'dependencies_test_helpers'
class Foo; end
class Bar < Foo
@@ -10,6 +11,7 @@ module FooBar; end
class ConstantLookupTest < ActiveSupport::TestCase
include ActiveSupport::Testing::ConstantLookup
+ include DependenciesTestHelpers
def find_foo(name)
self.class.determine_constant_from_test_name(name) do |constant|
@@ -56,4 +58,12 @@ def test_returns_nil_when_cant_find_module
assert_nil find_module("DoesntExist::Nadda::Nope")
assert_nil find_module("DoesntExist::Nadda::Nope::NotHere")
end
+
+ def test_does_not_swallow_exception_on_no_method_error
+ assert_raises(NoMethodError) {
+ with_autoloading_fixtures {
+ self.class.determine_constant_from_test_name("RaisesNoMethodError")
+ }
+ }
+ end
end

0 comments on commit 341e611

Please sign in to comment.