diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/autoloading_fixtures/a/b.rb | 2 | ||||
-rw-r--r-- | activesupport/test/autoloading_fixtures/a/c/d.rb | 2 | ||||
-rw-r--r-- | activesupport/test/autoloading_fixtures/e.rb | 2 | ||||
-rw-r--r-- | activesupport/test/class_inheritable_attributes_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/blank_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/class_test.rb | 37 | ||||
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 51 | ||||
-rw-r--r-- | activesupport/test/core_ext/object_and_class_ext_test.rb | 3 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 17 | ||||
-rw-r--r-- | activesupport/test/option_merger_test.rb | 2 |
10 files changed, 116 insertions, 4 deletions
diff --git a/activesupport/test/autoloading_fixtures/a/b.rb b/activesupport/test/autoloading_fixtures/a/b.rb new file mode 100644 index 0000000000..9c9e6454cf --- /dev/null +++ b/activesupport/test/autoloading_fixtures/a/b.rb @@ -0,0 +1,2 @@ +class A::B +end
\ No newline at end of file diff --git a/activesupport/test/autoloading_fixtures/a/c/d.rb b/activesupport/test/autoloading_fixtures/a/c/d.rb new file mode 100644 index 0000000000..0f40d6fbc4 --- /dev/null +++ b/activesupport/test/autoloading_fixtures/a/c/d.rb @@ -0,0 +1,2 @@ +class A::C::D +end
\ No newline at end of file diff --git a/activesupport/test/autoloading_fixtures/e.rb b/activesupport/test/autoloading_fixtures/e.rb new file mode 100644 index 0000000000..2f59e4fb75 --- /dev/null +++ b/activesupport/test/autoloading_fixtures/e.rb @@ -0,0 +1,2 @@ +class E +end
\ No newline at end of file diff --git a/activesupport/test/class_inheritable_attributes_test.rb b/activesupport/test/class_inheritable_attributes_test.rb index 9a472eacd2..36914e2bbf 100644 --- a/activesupport/test/class_inheritable_attributes_test.rb +++ b/activesupport/test/class_inheritable_attributes_test.rb @@ -1,5 +1,5 @@ require 'test/unit' -require File.dirname(__FILE__) + '/../lib/active_support/class_inheritable_attributes' +require File.dirname(__FILE__) + '/../lib/active_support/core_ext/class/inheritable_attributes' class ClassInheritableAttributesTest < Test::Unit::TestCase def setup diff --git a/activesupport/test/core_ext/blank_test.rb b/activesupport/test/core_ext/blank_test.rb index 2aba73a008..ff7345e774 100644 --- a/activesupport/test/core_ext/blank_test.rb +++ b/activesupport/test/core_ext/blank_test.rb @@ -1,5 +1,5 @@ require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object_and_class' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/blank' class BlankTest < Test::Unit::TestCase diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb new file mode 100644 index 0000000000..6e956fa45d --- /dev/null +++ b/activesupport/test/core_ext/class_test.rb @@ -0,0 +1,37 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' + +class A +end + +module X + class B + end +end + +module Y + module Z + class C + end + end +end + +class ClassTest < Test::Unit::TestCase + def test_removing_class_in_root_namespace + assert A.is_a?(Class) + Class.remove_class(A) + assert_raises(NameError) { A.is_a?(Class) } + end + + def test_removing_class_in_one_level_namespace + assert X::B.is_a?(Class) + Class.remove_class(X::B) + assert_raises(NameError) { X::B.is_a?(Class) } + end + + def test_removing_class_in_two_level_namespace + assert Y::Z::C.is_a?(Class) + Class.remove_class(Y::Z::C) + assert_raises(NameError) { Y::Z::C.is_a?(Class) } + end +end diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb new file mode 100644 index 0000000000..3d11f1001f --- /dev/null +++ b/activesupport/test/core_ext/module_test.rb @@ -0,0 +1,51 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/module' + +module One +end + +class Ab + include One +end + +module Xy + class Bc + include One + end +end + +module Yz + module Zy + class Cd + include One + end + end +end + +class De +end + +class ModuleTest < Test::Unit::TestCase + def test_included_in_classes + assert One.included_in_classes.include?(Ab) + assert One.included_in_classes.include?(Xy::Bc) + assert One.included_in_classes.include?(Yz::Zy::Cd) + assert !One.included_in_classes.include?(De) + end + + def test_remove_classes_including + assert Ab.is_a?(Class) + assert Xy::Bc.is_a?(Class) + assert Yz::Zy::Cd.is_a?(Class) + assert De.is_a?(Class) + + One.remove_classes_including + + assert_raises(NameError) { Ae.is_a?(Class) } + assert_raises(NameError) { Xy::Bc.is_a?(Class) } + assert_raises(NameError) { Yz::Zy::Cd.is_a?(Class) } + + assert De.is_a?(Class) + end +end
\ No newline at end of file diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index fc19183ede..5d7a06d08d 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -1,5 +1,6 @@ require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object_and_class' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' class ClassA; end class ClassB < ClassA; end diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index ab28c4668e..953a64a0ef 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -1,5 +1,6 @@ require 'test/unit' $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/active_support/' +require 'core_ext/string' require 'dependencies' class DependenciesTest < Test::Unit::TestCase @@ -99,4 +100,20 @@ class DependenciesTest < Test::Unit::TestCase $LOAD_PATH.shift Dependencies.mechanism = old_mechanism end + + def test_as_load_path + assert_equal '', DependenciesTest.as_load_path + end + + def test_module_loading + $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/autoloading_fixtures" + old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load + + assert_kind_of Module, A + assert_kind_of Class, A::B + assert_kind_of Class, A::C::D + ensure + $LOAD_PATH.shift + Dependencies.mechanism = old_mechanism + end end diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb index baa2cd30f3..f5287d5725 100644 --- a/activesupport/test/option_merger_test.rb +++ b/activesupport/test/option_merger_test.rb @@ -2,7 +2,7 @@ require 'test/unit' unless defined? ActiveSupport::OptionMerger require File.dirname(__FILE__) + '/../lib/active_support/option_merger' - require File.dirname(__FILE__) + '/../lib/active_support/core_ext/object_and_class' + require File.dirname(__FILE__) + '/../lib/active_support/core_ext/object' end class OptionMergerTest < Test::Unit::TestCase |