Permalink
Browse files

Add regression test for NameError#name

  • Loading branch information...
1 parent b36df0f commit bd3fde093112275bef5ab71bfac7ca17e43af8b8 @arthurnn arthurnn committed Jun 20, 2014
Showing with 5 additions and 2 deletions.
  1. +1 −1 activesupport/lib/active_support/dependencies.rb
  2. +4 −1 activesupport/test/dependencies_test.rb
@@ -187,7 +187,7 @@ def const_missing(const_name)
# top-level constant.
def guess_for_anonymous(const_name)
if Object.const_defined?(const_name)
- raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name
+ raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name.to_s
else
Object
end
@@ -367,9 +367,11 @@ def test_non_existing_const_raises_name_error_with_fully_qualified_name
with_autoloading_fixtures do
e = assert_raise(NameError) { A::DoesNotExist.nil? }
assert_equal "uninitialized constant A::DoesNotExist", e.message
+ assert_equal "A::DoesNotExist", e.name
e = assert_raise(NameError) { A::B::DoesNotExist.nil? }
assert_equal "uninitialized constant A::B::DoesNotExist", e.message
+ assert_equal "A::B::DoesNotExist", e.name
end
end
@@ -537,6 +539,7 @@ def test_const_missing_in_anonymous_modules_raises_if_the_constant_belongs_to_Ob
mod = Module.new
e = assert_raise(NameError) { mod::E }
assert_equal 'E cannot be autoloaded from an anonymous class or module', e.message
+ assert_equal 'E', e.name
end
end
@@ -954,7 +957,7 @@ def test_access_unloaded_constants_for_reload
assert_kind_of Class, A::B # Necessary to load A::B for the test
ActiveSupport::Dependencies.mark_for_unload(A::B)
ActiveSupport::Dependencies.remove_unloadable_constants!
-
+
A::B # Make sure no circular dependency error
end
end

0 comments on commit bd3fde0

Please sign in to comment.