diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-08-16 20:54:25 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-08-16 20:54:25 +0000 |
commit | 2b37d59976268013b7e518e5af244947f688d315 (patch) | |
tree | 2ad49e2e529da6c805d3d623e873e442e6335ac4 /activesupport/test | |
parent | 38f598ec0b28919ff0d996bcb9ed923fbd99316f (diff) | |
download | rails-2b37d59976268013b7e518e5af244947f688d315.tar.gz rails-2b37d59976268013b7e518e5af244947f688d315.tar.bz2 rails-2b37d59976268013b7e518e5af244947f688d315.zip |
Fix const_missing to behave responsibly when called within anonymous modules
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4779 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/dependencies_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index f4b173101b..f043bbd438 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -346,10 +346,28 @@ class DependenciesTest < Test::Unit::TestCase end def test_const_missing_should_not_double_load + $counting_loaded_times = 0 with_loading 'autoloading_fixtures' do require_dependency '././counting_loader' assert_equal 1, $counting_loaded_times - Dependencies.load_missing_constant Object, :CountingLoader + assert_raises(ArgumentError) { Dependencies.load_missing_constant Object, :CountingLoader } + assert_equal 1, $counting_loaded_times + end + end + + def test_const_missing_within_anonymous_module + $counting_loaded_times = 0 + m = Module.new + m.module_eval "def a() CountingLoader; end" + extend m + kls = nil + with_loading 'autoloading_fixtures' do + kls = nil + assert_nothing_raised { kls = a } + assert_equal "CountingLoader", kls.name + assert_equal 1, $counting_loaded_times + + assert_nothing_raised { kls = a } assert_equal 1, $counting_loaded_times end end |