aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2014-06-20 09:55:41 -0400
committerArthur Neves <arthurnn@gmail.com>2014-06-20 09:55:41 -0400
commitbd3fde093112275bef5ab71bfac7ca17e43af8b8 (patch)
treed9591075f6c739f90c9b2ae2747e87431f610d78
parentb36df0f6c8e1af0a35b892c72d4ec0fbd30ec3ab (diff)
downloadrails-bd3fde093112275bef5ab71bfac7ca17e43af8b8.tar.gz
rails-bd3fde093112275bef5ab71bfac7ca17e43af8b8.tar.bz2
rails-bd3fde093112275bef5ab71bfac7ca17e43af8b8.zip
Add regression test for NameError#name
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/test/dependencies_test.rb5
2 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index d7db0d6648..a8d12366cc 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -187,7 +187,7 @@ module ActiveSupport #:nodoc:
# 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
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index 4ca63b3417..ef0955e1a8 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -367,9 +367,11 @@ class DependenciesTest < ActiveSupport::TestCase
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 @@ class DependenciesTest < ActiveSupport::TestCase
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 @@ class DependenciesTest < ActiveSupport::TestCase
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