[macruby-changes] [1337] MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec. rb

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 4 08:23:31 PDT 2009


Revision: 1337
          http://trac.macosforge.org/projects/ruby/changeset/1337
Author:   eloy.de.enige at gmail.com
Date:     2009-04-04 08:23:31 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
make eigenclass specs apply to both 1.8 and 1.9 where appropriate. Also adds a spec for making sure that a new eigenclass method is public

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb

Modified: MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb	2009-04-04 15:23:21 UTC (rev 1336)
+++ MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb	2009-04-04 15:23:31 UTC (rev 1337)
@@ -183,93 +183,119 @@
   end
 end
 
-# TODO: write these for 1.8.
-ruby_version_is "1.9" do
-  describe "Instance methods of an eigenclass" do
-    it "includes ones of the object's class" do
-      (class << ClassSpecs::K.new; self end).instance_methods.should include(:example_instance_method)
+describe "Defining instance methods on an eigenclass" do
+  before :each do
+    @k = ClassSpecs::K.new
+    class << @k
+      def singleton_method; 1 end
     end
 
-    it "does not include class methods of the object's class" do
-      (class << ClassSpecs::K.new; self end).instance_methods.should_not include(:example_class_method)
-    end
+    @k_eigenclass = class << @k; self end
+  end
+  
+  it "define public methods" do
+    @k_eigenclass.should have_public_instance_method(:singleton_method)
+  end
+end
 
-    it "includes instance methods of Object" do
-      (class << ClassSpecs::A.new; self end).instance_methods.should include(:example_instance_method_of_object)
-    end
+describe "Instance methods of an eigenclass" do
+  before :each do
+    @k = ClassSpecs::K.new
 
-    it "does not include class methods of Object" do
-      (class << ClassSpecs::A.new; self end).instance_methods.should_not include(:example_class_method_of_object)
-    end
+    def @k.singleton_method; 1 end
+    @k_eigenclass = class << @k; self end
+    @a_eigenclass = class << ClassSpecs::A.new; self end
+    @a_class_eigenclass = class << ClassSpecs::A; self end
+  end
 
-    it "includes instance methods of Class, for a class" do
-      (class << ClassSpecs::A; self end).instance_methods.should include(:example_instance_method_of_class)
-    end
+  it "includes ones of the object's class" do
+    @k_eigenclass.should have_instance_method(:example_instance_method)
+  end
 
-    it "does not include class methods of Class, for a class" do
-      (class << ClassSpecs::A; self end).instance_methods.should_not include(:example_class_method_of_class)
-    end
+  it "does not include class methods of the object's class" do
+    @k_eigenclass.should_not have_instance_method(:example_class_method)
+  end
 
-    it "does not include instance methods of the metaclass of Class, for a class" do
-      (class << ClassSpecs::A; self end).instance_methods.should_not include(:example_instance_method_of_metaclass)
-    end
+  it "includes instance methods of Object" do
+    @a_eigenclass.should have_instance_method(:example_instance_method_of_object)
+  end
 
-    it "does not include class methods of the metaclass of Class, for a class" do
-      (class << ClassSpecs::A; self end).instance_methods.should_not include(:example_class_method_of_metaclass)
-    end
+  it "does not include class methods of Object" do
+    @a_eigenclass.should_not have_instance_method(:example_class_method_of_object)
+  end
 
-    it "includes instance methods of the metaclass of Class, for a metaclass" do
-      metaclass = class << ClassSpecs::A; self end
-      (class << metaclass; self end).instance_methods.should include(:example_instance_method_of_metaclass)
-    end
+  it "includes instance methods of Class, for a class" do
+    @a_class_eigenclass.should have_instance_method(:example_instance_method_of_class)
+  end
 
-    it "does not include class methods of the metaclass of Class, for a metaclass" do
-      metaclass = class << ClassSpecs::A; self end
-      (class << metaclass; self end).instance_methods.should_not include(:example_class_method_of_metaclass)
-    end
+  it "does not include class methods of Class, for a class" do
+    @a_class_eigenclass.should_not have_instance_method(:example_class_method_of_class)
   end
 
-  describe "Class methods of an eigenclass" do
-    it "includes ones of the object's class" do
-      (class << ClassSpecs::K.new; self end).methods.should include(:example_class_method)
-    end
+  it "does not include instance methods of the metaclass of Class, for a class" do
+    @a_class_eigenclass.should_not have_instance_method(:example_instance_method_of_metaclass)
+  end
 
-    it "does not include instance methods of the object's class" do
-      (class << ClassSpecs::K.new; self end).methods.should_not include(:example_instance_method)
-    end
+  it "does not include class methods of the metaclass of Class, for a class" do
+    @a_class_eigenclass.should_not have_instance_method(:example_class_method_of_metaclass)
+  end
 
-    it "includes instance methods of Class" do
-      (class << ClassSpecs::A.new; self end).methods.should include(:example_instance_method_of_class)
-    end
+  it "includes instance methods of the metaclass of Class, for a metaclass" do
+    (class << @a_class_eigenclass; self end).should have_instance_method(:example_instance_method_of_metaclass)
+  end
 
-    it "does not include class mtehods of Class" do
-      (class << ClassSpecs::A.new; self end).methods.should_not include(:example_class_method_of_class)
-    end
+  it "does not include class methods of the metaclass of Class, for a metaclass" do
+    (class << @a_class_eigenclass; self end).should_not have_instance_method(:example_class_method_of_metaclass)
+  end
+end
 
-    it "includes instance methods of Class, for a class" do
-      (class << ClassSpecs::A; self end).methods.should include(:example_instance_method_of_class)
-    end
+describe "Class methods of an eigenclass" do
+  before :each do
+    @k = ClassSpecs::K.new
+    @k_eigenclass = class << @k; self end
+    @a_eigenclass = class << ClassSpecs::A.new; self end
+    @a_class_eigenclass = class << ClassSpecs::A; self end
+  end
 
-    it "includes class methods of Class, for a class" do
-      (class << ClassSpecs::A; self end).methods.should include(:example_class_method_of_class)
-    end
+  it "includes ones of the object's class" do
+    @k_eigenclass.should have_method(:example_class_method)
+  end
 
-    it "includes instance methods of the metaclass of Class, for a class" do
-      (class << ClassSpecs::A; self end).methods.should include(:example_instance_method_of_metaclass)
-    end
+  it "does not include instance methods of the object's class" do
+    @k_eigenclass.should_not have_method(:example_instance_method)
+  end
 
-    it "does not include class methods of the metaclass of Class, for a class" do
-      (class << ClassSpecs::A; self end).methods.should_not include(:example_class_method_of_metaclass)
-    end
+  it "includes instance methods of Class" do
+    @a_eigenclass.should have_method(:example_instance_method_of_class)
+  end
 
-    it "includes instance methods of the metaclass of Class, for a metaclass" do
-      metaclass = class << ClassSpecs::A; self end
-      (class << metaclass; self end).methods.should include(:example_instance_method_of_metaclass)
-    end
+  it "does not include class mtehods of Class" do
+    @a_eigenclass.should_not have_method(:example_class_method_of_class)
+  end
 
+  it "includes instance methods of Class, for a class" do
+    @a_class_eigenclass.should have_method(:example_instance_method_of_class)
+  end
+
+  it "includes class methods of Class, for a class" do
+    @a_class_eigenclass.should have_method(:example_class_method_of_class)
+  end
+
+  it "includes instance methods of the metaclass of Class, for a class" do
+    @a_class_eigenclass.should have_method(:example_instance_method_of_metaclass)
+  end
+
+  it "does not include class methods of the metaclass of Class, for a class" do
+    @a_class_eigenclass.should_not have_method(:example_class_method_of_metaclass)
+  end
+
+  it "includes instance methods of the metaclass of Class, for a metaclass" do
+    (class << @a_class_eigenclass; self end).should have_method(:example_instance_method_of_metaclass)
+  end
+
+  ruby_version_is "1.9" do
     it "includes class methods of the metaclass of Class, for a metaclass" do
-      metaclass = class << ClassSpecs::A; self end
-      (class << metaclass; self end).methods.should include(:example_class_method_of_metaclass)
+      (class << @a_class_eigenclass; self end).should have_method(:example_class_method_of_metaclass)
     end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/0a505040/attachment-0001.html>


More information about the macruby-changes mailing list