[macruby-changes] [1845] MacRuby/branches/experimental/spec/macruby/language/objc_method_spec .rb

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 11 23:28:52 PDT 2009


Revision: 1845
          http://trac.macosforge.org/projects/ruby/changeset/1845
Author:   lsansonetti at apple.com
Date:     2009-06-11 23:28:50 -0700 (Thu, 11 Jun 2009)
Log Message:
-----------
added a spec to cover the -forwardInvocation: support, using NSUndoManager

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb

Modified: MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb	2009-06-12 06:28:12 UTC (rev 1844)
+++ MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb	2009-06-12 06:28:50 UTC (rev 1845)
@@ -649,3 +649,37 @@
     TestMethod.testInformalProtocolMethod2(@o).should == 1 
   end
 end
+
+describe "A pure MacRuby method" do
+  before :each do
+    @um = NSUndoManager.new
+    @o = Object.new
+    @o.instance_variable_set(:'@a', [])
+    def @o.foo(x)
+       @a << x
+    end
+    def @o.a
+      @a
+    end
+  end
+
+  it "can be forwarded by NSUndoManager" do
+    @um.canUndo.should == false
+    @um.prepareWithInvocationTarget(@o)
+    @um.foo(42)
+    @um.canUndo.should == true
+
+    @o.a.should == []
+    @um.undo
+    @o.a.should == [42]
+
+    @um.canUndo.should == false
+    @um.prepareWithInvocationTarget(@o)
+    @um.foo(42)
+    @um.canUndo.should == true
+
+    @um.undo
+    @o.a.should == [42, 42]
+    @um.canUndo.should == false
+  end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090611/07de1d73/attachment.html>


More information about the macruby-changes mailing list