From 9e799a71784e1112a048eb61b5a3acdf33418398 Mon Sep 17 00:00:00 2001 From: Jonathan Lim Date: Wed, 28 Jan 2009 06:46:11 +0800 Subject: [PATCH] Ensuring method names unique. Ensuring that later class method definitions don't mess with earlier tests. Renaming test to reflect that other objects are not affected by singleton methods on objects. Signed-off-by: edgecase --- koans/about_class_methods.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/koans/about_class_methods.rb b/koans/about_class_methods.rb index c318403..39ede95 100644 --- a/koans/about_class_methods.rb +++ b/koans/about_class_methods.rb @@ -9,7 +9,7 @@ class AboutClassMethods < EdgeCase::Koan assert_equal __, fido.is_a?(Object) end - def test_classes_are_objects_too + def test_classes_are_classes assert_equal __, Dog.is_a?(Class) end @@ -34,7 +34,7 @@ class AboutClassMethods < EdgeCase::Koan assert_equal __, fido.wag end - def test_other_objects_are_affected_by_these_singleton_methods + def test_other_objects_are_not_affected_by_these_singleton_methods fido = Dog.new rover = Dog.new def fido.wag @@ -48,24 +48,24 @@ class AboutClassMethods < EdgeCase::Koan # ------------------------------------------------------------------ - def Dog.wag - :class_level_wag - end - - class Dog + class Dog2 def wag :instance_level_wag end end + def Dog2.wag + :class_level_wag + end + def test_since_classes_are_objects_you_can_define_singleton_methods_on_them_too - assert_equal __, Dog.a_class_method + assert_equal __, Dog2.wag end def test_class_methods_are_independent_of_instance_methods - fido = Dog.new + fido = Dog2.new assert_equal __, fido.wag - assert_equal __, Dog.wag + assert_equal __, Dog2.wag end # ------------------------------------------------------------------