mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add regression test for NameError#name
This commit is contained in:
parent
b36df0f6c8
commit
bd3fde0931
2 changed files with 5 additions and 2 deletions
|
@ -187,7 +187,7 @@ module ActiveSupport #:nodoc:
|
||||||
# top-level constant.
|
# top-level constant.
|
||||||
def guess_for_anonymous(const_name)
|
def guess_for_anonymous(const_name)
|
||||||
if Object.const_defined?(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
|
else
|
||||||
Object
|
Object
|
||||||
end
|
end
|
||||||
|
|
|
@ -367,9 +367,11 @@ class DependenciesTest < ActiveSupport::TestCase
|
||||||
with_autoloading_fixtures do
|
with_autoloading_fixtures do
|
||||||
e = assert_raise(NameError) { A::DoesNotExist.nil? }
|
e = assert_raise(NameError) { A::DoesNotExist.nil? }
|
||||||
assert_equal "uninitialized constant A::DoesNotExist", e.message
|
assert_equal "uninitialized constant A::DoesNotExist", e.message
|
||||||
|
assert_equal "A::DoesNotExist", e.name
|
||||||
|
|
||||||
e = assert_raise(NameError) { A::B::DoesNotExist.nil? }
|
e = assert_raise(NameError) { A::B::DoesNotExist.nil? }
|
||||||
assert_equal "uninitialized constant A::B::DoesNotExist", e.message
|
assert_equal "uninitialized constant A::B::DoesNotExist", e.message
|
||||||
|
assert_equal "A::B::DoesNotExist", e.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -537,6 +539,7 @@ class DependenciesTest < ActiveSupport::TestCase
|
||||||
mod = Module.new
|
mod = Module.new
|
||||||
e = assert_raise(NameError) { mod::E }
|
e = assert_raise(NameError) { mod::E }
|
||||||
assert_equal 'E cannot be autoloaded from an anonymous class or module', e.message
|
assert_equal 'E cannot be autoloaded from an anonymous class or module', e.message
|
||||||
|
assert_equal 'E', e.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue