spec/cg_point_spec.rb in geomotion-0.5 vs spec/cg_point_spec.rb in geomotion-0.7.0

- old
+ new

@@ -18,18 +18,71 @@ size = CGSizeMake(20, 30) @point.rect_of_size(size).should == CGRectMake(10, 20, 20, 30) end end + describe "#up" do + it "should work" do + point = CGPointMake(1, 1).up(1) + CGPointEqualToPoint(point, CGPointMake(1, 0)).should == true + end + end + + describe "#down" do + it "should work" do + point = CGPointMake(1, 1).down(1) + CGPointEqualToPoint(point, CGPointMake(1, 2)).should == true + end + end + + describe "#left" do + it "should work" do + point = CGPointMake(1, 1).left(1) + CGPointEqualToPoint(point, CGPointMake(0, 1)).should == true + end + end + + describe "#right" do + it "should work" do + point = CGPointMake(1, 1).right(1) + CGPointEqualToPoint(point, CGPointMake(2, 1)).should == true + end + end + + describe "#chaining up().down().left().right()" do + it "should work" do + point = CGPointMake(1, 1).up(2).down(1).left(2).right(1) + CGPointEqualToPoint(point, CGPointMake(0, 0)).should == true + end + end + describe "#+" do it "should work with CGSize" do size = CGSizeMake(20, 30) (@point + size).should == CGRectMake(10, 20, 20, 30) end it "should work with CGPoint" do point = CGPoint.make(x: 100, y: 200) (@point + point).should == CGPointMake(110, 220) + end + end + + describe "#*" do + it "should work with Numeric" do + point = CGPointMake(12, 24) + bigger = point * 3 + bigger.x.should == 36 + bigger.y.should == 72 + end + end + + describe "#/" do + it "should work with Numeric" do + point = CGPointMake(12, 24) + smaller = point / 3 + smaller.x.should == 4 + smaller.y.should == 8 end end describe "#- (unary)" do it "should work" do \ No newline at end of file