diff options
Diffstat (limited to 'activesupport/test/dependencies_test.rb')
-rw-r--r-- | activesupport/test/dependencies_test.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index ef017d7436..fe8f51e11a 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -1,7 +1,6 @@ require 'abstract_unit' require 'pp' require 'active_support/dependencies' -require 'active_support/core_ext/kernel/reporting' module ModuleWithMissing mattr_accessor :missing_count @@ -24,11 +23,13 @@ class DependenciesTest < Test::Unit::TestCase old_mechanism, ActiveSupport::Dependencies.mechanism = ActiveSupport::Dependencies.mechanism, :load this_dir = File.dirname(__FILE__) parent_dir = File.dirname(this_dir) + path_copy = $LOAD_PATH.dup $LOAD_PATH.unshift(parent_dir) unless $LOAD_PATH.include?(parent_dir) prior_autoload_paths = ActiveSupport::Dependencies.autoload_paths ActiveSupport::Dependencies.autoload_paths = from.collect { |f| "#{this_dir}/#{f}" } yield ensure + $LOAD_PATH.replace(path_copy) ActiveSupport::Dependencies.autoload_paths = prior_autoload_paths ActiveSupport::Dependencies.mechanism = old_mechanism ActiveSupport::Dependencies.explicitly_unloadable_constants = [] @@ -439,7 +440,7 @@ class DependenciesTest < Test::Unit::TestCase with_autoloading_fixtures do require_dependency '././counting_loader' assert_equal 1, $counting_loaded_times - assert_raise(ArgumentError) { ActiveSupport::Dependencies.load_missing_constant Object, :CountingLoader } + assert_raise(NameError) { ActiveSupport::Dependencies.load_missing_constant Object, :CountingLoader } assert_equal 1, $counting_loaded_times end end @@ -519,6 +520,24 @@ class DependenciesTest < Test::Unit::TestCase ActiveSupport::Dependencies.autoload_once_paths = [] end + def test_autoload_once_pathnames_do_not_add_to_autoloaded_constants + with_autoloading_fixtures do + pathnames = ActiveSupport::Dependencies.autoload_paths.collect{|p| Pathname.new(p)} + ActiveSupport::Dependencies.autoload_paths = pathnames + ActiveSupport::Dependencies.autoload_once_paths = pathnames + + assert ! ActiveSupport::Dependencies.autoloaded?("ModuleFolder") + assert ! ActiveSupport::Dependencies.autoloaded?("ModuleFolder::NestedClass") + assert ! ActiveSupport::Dependencies.autoloaded?(ModuleFolder) + + 1 if ModuleFolder::NestedClass # 1 if to avoid warning + assert ! ActiveSupport::Dependencies.autoloaded?(ModuleFolder::NestedClass) + end + ensure + Object.class_eval { remove_const :ModuleFolder } + ActiveSupport::Dependencies.autoload_once_paths = [] + end + def test_application_should_special_case_application_controller with_autoloading_fixtures do require_dependency 'application' |