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

- old
+ new

@@ -46,13 +46,32 @@ point = CGPointMake(1, 1).right(1) CGPointEqualToPoint(point, CGPointMake(2, 1)).should == true end end - describe "#chaining up().down().left().right()" do + 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 "#distance_to" do + it "should work" do + point = CGPoint.make(x: 10, y: 100) + point.distance_to(CGPoint.make(x: 13, y:104)).should == 5 + point.distance_to(CGPoint.make(x: 14, y:103)).should == 5 + end + end + + describe "#angle_to" do + it "should work" do + point = CGPoint.make(x: 0, y: 0) + point.angle_to(CGPoint.make(x: 10, y:0)).should == 0 + (0.785 - point.angle_to(CGPoint.make(x: 10, y:10))).abs.should < 0.01 # ~= Math::PI/4 + (1.57 - point.angle_to(CGPoint.make(x: 0, y:10))).abs.should < 0.01 # ~= Math::PI/2 + (3.14 - point.angle_to(CGPoint.make(x: -10, y:0))).abs.should < 0.01 # ~= Math::PI + (-1.57 - point.angle_to(CGPoint.make(x: 0, y:-10))).abs.should < 0.01 # ~= -Math::PI/2 end end describe "#+" do it "should work with CGSize" do \ No newline at end of file