diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-01-26 15:38:49 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-01-26 15:38:49 -0800 |
commit | aef76d1e7120a16e0cace1ca89c327c70cbaddf3 (patch) | |
tree | f08da969bc8289aed4d0d9ed0c95c637d6ae8f74 /activesupport/test | |
parent | 458b6a7fc905a23643fc0d26146e6bf230c9c472 (diff) | |
parent | 3c6891593d84b83c70441b4c953080481bdcc4bf (diff) | |
download | rails-aef76d1e7120a16e0cace1ca89c327c70cbaddf3.tar.gz rails-aef76d1e7120a16e0cace1ca89c327c70cbaddf3.tar.bz2 rails-aef76d1e7120a16e0cace1ca89c327c70cbaddf3.zip |
Merge remote branch 'fxn/master'
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/class_test.rb | 47 | ||||
-rw-r--r-- | activesupport/test/core_ext/object_and_class_ext_test.rb | 93 |
2 files changed, 0 insertions, 140 deletions
diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb deleted file mode 100644 index bb4eb3c7d5..0000000000 --- a/activesupport/test/core_ext/class_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'abstract_unit' -require '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_raise(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_raise(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_raise(NameError) { Y::Z::C.is_a?(Class) } - end - - def test_retrieving_subclasses - @parent = eval("class D; end; D") - @sub = eval("class E < D; end; E") - @subofsub = eval("class F < E; end; F") - assert_equal 2, @parent.subclasses.size - assert_equal [@subofsub.to_s], @sub.subclasses - assert_equal [], @subofsub.subclasses - assert_equal [@sub.to_s, @subofsub.to_s].sort, @parent.subclasses.sort - end -end 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 e6fbdb637b..0b2a9c418e 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -1,7 +1,6 @@ require 'abstract_unit' require 'active_support/time' require 'active_support/core_ext/object' -require 'active_support/core_ext/class/removal' class ClassA; end class ClassB < ClassA; end @@ -40,99 +39,7 @@ class Foo include Bar end -class ClassExtTest < Test::Unit::TestCase - def test_methods - assert defined?(ClassB) - assert defined?(ClassC) - assert defined?(ClassD) - - ClassA.remove_subclasses - - assert !defined?(ClassB) - assert !defined?(ClassC) - assert !defined?(ClassD) - end - - def test_subclasses_of - cj = ClassJ - assert_equal [ClassJ], Object.subclasses_of(ClassI) - ClassI.remove_subclasses - assert_equal [], Object.subclasses_of(ClassI) - ensure - Object.const_set :ClassJ, cj - end - - def test_subclasses_of_should_find_nested_classes - assert Object.subclasses_of(ClassK).include?(Nested::ClassL) - end - - def test_subclasses_of_should_not_return_removed_classes - # First create the removed class - old_class = Nested.class_eval { remove_const :ClassL } - new_class = Class.new(ClassK) - Nested.const_set :ClassL, new_class - assert_equal "Nested::ClassL", new_class.name # Sanity check - - subclasses = Object.subclasses_of(ClassK) - assert subclasses.include?(new_class) - assert ! subclasses.include?(old_class) - ensure - Nested.const_set :ClassL, old_class unless defined?(Nested::ClassL) - end - - def test_subclasses_of_should_not_trigger_const_missing - const_missing = false - Nested.on_const_missing { const_missing = true } - - subclasses = Object.subclasses_of ClassK - assert !const_missing - assert_equal [ Nested::ClassL ], subclasses - - removed = Nested.class_eval { remove_const :ClassL } # keep it in memory - subclasses = Object.subclasses_of ClassK - assert !const_missing - assert subclasses.empty? - ensure - Nested.const_set :ClassL, removed unless defined?(Nested::ClassL) - end - - def test_subclasses_of_with_multiple_roots - classes = Object.subclasses_of(ClassI, ClassK) - assert_equal %w(ClassJ Nested::ClassL), classes.collect(&:to_s).sort - end - - def test_subclasses_of_doesnt_find_anonymous_classes - assert_equal [], Object.subclasses_of(Foo) - bar = Class.new(Foo) - assert_nothing_raised do - assert_equal [bar], Object.subclasses_of(Foo) - end - end -end - class ObjectTests < Test::Unit::TestCase - def test_extended_by - foo = Foo.new - assert foo.extended_by.include?(Bar) - foo.extend(Baz) - assert(([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}") - end - - def test_extend_with_included_modules_from - foo, object = Foo.new, Object.new - assert !object.respond_to?(:bar) - assert !object.respond_to?(:baz) - - object.extend_with_included_modules_from(foo) - assert object.respond_to?(:bar) - assert !object.respond_to?(:baz) - - foo.extend(Baz) - object.extend_with_included_modules_from(foo) - assert object.respond_to?(:bar) - assert object.respond_to?(:baz) - end - class DuckTime def acts_like_time? true |