spec/patternmatching_spec.rb in patternmatching-0.1.2 vs spec/patternmatching_spec.rb in patternmatching-0.1.3
- old
+ new
@@ -41,10 +41,30 @@
attr :name
attr :age
end
include PatternMatching
+class PartialStyleDefs
+ def initialize
+ @name = "Foo"
+ end
+ attr :name
+
+ def bar
+ make "bar" do
+ seems as {:val} do
+ @name = val
+ end
+ end
+ end
+
+ func(:buzz).seems as {:val} do
+ @name = val
+ end
+end
+
+
def calc(code)
make(code) {
seems as {plus(:a, :b)} do calc(a) + calc(b) end
seems as {mul(:a, :b)} do calc(a) * calc(b) end
seems something do code end
@@ -156,7 +176,16 @@
seems something do
nil
end
end
result.should == [120, 200]
+ end
+
+ it "should update fields from block" do
+ o = PartialStyleDefs.new
+ o.name.should == "Foo"
+ o.bar
+ o.name.should == "bar"
+ o.buzz("buzz")
+ o.name.should == "buzz"
end
end