mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
determine_constant_from_test_name does not swallow NoMethodErrors [Yves Senn]
This commit is contained in:
parent
0417bc8316
commit
341e611547
2 changed files with 12 additions and 0 deletions
|
@ -38,6 +38,8 @@ module ActiveSupport
|
|||
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 @@ class ConstantLookupTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue