spec/cg_rect_spec.rb in geomotion-0.13.0 vs spec/cg_rect_spec.rb in geomotion-0.13.1
- old
+ new
@@ -286,142 +286,213 @@
end
end
describe "#left" do
it "works" do
- rect = CGRect.empty
- rect = rect.left(20)
+ rect = CGRect.empty.left(20)
rect.origin.x.should == -20
end
+
+ it "works with options" do
+ rect = CGRect.empty.left(20, width: 20)
+ rect.origin.x.should == -20
+ rect.size.width.should == 20
+ end
end
describe "#right" do
it "works" do
rect = CGRect.empty.right(20)
rect.origin.x.should == 20
end
+
+ it "works with options" do
+ rect = CGRect.empty.right(20, width: 20)
+ rect.origin.x.should == 20
+ rect.size.width.should == 20
+ end
end
describe "#up" do
it "works" do
rect = CGRect.empty.up(20)
rect.origin.y.should == -20
end
+
+ it "works with options" do
+ rect = CGRect.empty.up(20, height: 20)
+ rect.origin.y.should == -20
+ rect.size.height.should == 20
+ end
end
describe "#down" do
it "works" do
rect = CGRect.empty.down(20)
rect.origin.y.should == 20
end
+
+ it "works with options" do
+ rect = CGRect.empty.down(20, height: 20)
+ rect.origin.y.should == 20
+ rect.size.height.should == 20
+ end
end
describe "#wider" do
it "works" do
rect = CGRect.empty.wider(20)
rect.size.width.should == 20
end
+
+ it "works with options" do
+ rect = CGRect.empty.wider(20, height: 20)
+ rect.size.width.should == 20
+ rect.size.height.should == 20
+ end
end
describe "#thinner" do
it "works" do
- rect = CGRect.empty.thinner(20)
- rect.size.width.should == -20
+ rect = CGRect.make(width: 20).thinner(10)
+ rect.size.width.should == 10
end
+
+ it "works with options" do
+ rect = CGRect.make(width: 20).thinner(10, height: 20)
+ rect.size.width.should == 10
+ rect.size.height.should == 20
+ end
end
describe "#taller" do
it "works" do
- rect = CGRect.empty.taller(20)
- rect.size.height.should == 20
+ rect = CGRect.make(height: 20).taller(20)
+ rect.size.height.should == 40
end
+
+ it "works with options" do
+ rect = CGRect.make(height: 20).taller(20, width: 20)
+ rect.size.width.should == 20
+ rect.size.height.should == 40
+ end
end
describe "#shorter" do
it "works" do
- rect = CGRect.empty.shorter(20)
- rect.size.height.should == -20
+ rect = CGRect.make(height: 20).shorter(10)
+ rect.size.height.should == 10
end
+
+ it "works with options" do
+ rect = CGRect.make(height: 20).shorter(10, width: 20)
+ rect.size.width.should == 20
+ rect.size.height.should == 10
+ end
end
describe "#above" do
+ it "works without margins" do
+ rect = CGRect.make(height: 50).above
+ rect.origin.y.should == -50
+ rect.size.height.should == 50
+ end
+
it "works with margins" do
rect = CGRect.make(height: 50).above(20)
rect.origin.y.should == -70
rect.size.height.should == 50
end
- it "works with height" do
+ it "works with options" do
rect = CGRect.make(height: 50).above(20, height: 10)
rect.origin.y.should == -30
rect.size.height.should == 10
end
- it "works without margins" do
- rect = CGRect.make(height: 50).above
- rect.origin.y.should == -50
- rect.size.height.should == 50
+ it "works with options and no margin" do
+ rect = CGRect.make(height: 50).above(height: 10)
+ rect.origin.y.should == -10
+ rect.size.height.should == 10
end
end
describe "#below" do
+ it "works without margins" do
+ rect = CGRect.make(height: 50).below
+ rect.origin.y.should == 50
+ rect.size.height.should == 50
+ end
+
it "works with margins" do
rect = CGRect.make(height: 50).below(20)
rect.origin.y.should == 70
rect.size.height.should == 50
end
- it "works with height" do
+ it "works with options" do
rect = CGRect.make(height: 50).below(20, height: 10)
rect.origin.y.should == 70
rect.size.height.should == 10
end
- it "works without margins" do
- rect = CGRect.make(height: 50).below
+ it "works with options and no margin" do
+ rect = CGRect.make(height: 50).below(height: 10)
rect.origin.y.should == 50
- rect.size.height.should == 50
+ rect.size.height.should == 10
end
end
describe "#before" do
+ it "works without margins" do
+ rect = CGRect.make(width: 50).before
+ rect.origin.x.should == -50
+ rect.size.width.should == 50
+ end
+
it "works with margins" do
rect = CGRect.make(width: 50).before(20)
rect.origin.x.should == -70
rect.size.width.should == 50
end
- it "works with width" do
+ it "works with options" do
rect = CGRect.make(width: 50).before(20, width: 10)
rect.origin.x.should == -30
rect.size.width.should == 10
end
- it "works without margins" do
- rect = CGRect.make(width: 50).before
- rect.origin.x.should == -50
- rect.size.width.should == 50
+ it "works with options and no margin" do
+ rect = CGRect.make(width: 50).before(width: 10)
+ rect.origin.x.should == -10
+ rect.size.width.should == 10
end
end
describe "#beside" do
+ it "works without margins" do
+ rect = CGRect.make(width: 50).beside
+ rect.origin.x.should == 50
+ rect.size.width.should == 50
+ end
+
it "works with margins" do
rect = CGRect.make(width: 50).beside(20)
rect.origin.x.should == 70
rect.size.width.should == 50
end
- it "works with width" do
+ it "works with options" do
rect = CGRect.make(width: 50).beside(20, width: 10)
rect.origin.x.should == 70
rect.size.width.should == 10
end
- it "works without margins" do
- rect = CGRect.make(width: 50).beside
+ it "works with options and no margin" do
+ rect = CGRect.make(width: 50).beside(width: 10)
rect.origin.x.should == 50
- rect.size.width.should == 50
+ rect.size.width.should == 10
end
end
describe "#top_left" do
it "works with margins" do
@@ -709,10 +780,54 @@
rect = @rect.grow(CGSizeMake(10, 20))
rect.should == CGRectMake(0, 80, 70, 60)
end
end
+ describe "#grow_left" do
+ # @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
+ it "should work" do
+ rect = @rect.grow_left(10)
+ rect.should == CGRectMake(0, 100, 60, 20)
+ end
+ end
+
+ describe "#grow_right" do
+ it "should work" do
+ rect = @rect.grow_right(10)
+ rect.should == CGRectMake(10, 100, 60, 20)
+ end
+ end
+
+ describe "#grow_up" do
+ it "should work" do
+ rect = @rect.grow_up(10)
+ rect.should == CGRectMake(10, 90, 50, 30)
+ end
+ end
+
+ describe "#grow_down" do
+ it "should work" do
+ rect = @rect.grow_down(10)
+ rect.should == CGRectMake(10, 100, 50, 30)
+ end
+ end
+
+ describe "#grow_width" do
+ # @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
+ it "should work" do
+ rect = @rect.grow_width(10)
+ rect.should == CGRectMake(0, 100, 70, 20)
+ end
+ end
+
+ describe "#grow_height" do
+ it "should work" do
+ rect = @rect.grow_height(10)
+ rect.should == CGRectMake(10, 90, 50, 40)
+ end
+ end
+
describe "#shrink" do
it "should work with Numeric" do
rect = @rect.shrink(10)
rect.should == CGRectMake(20, 110, 30, 0)
end
@@ -723,9 +838,52 @@
end
it "should work with Array" do
rect = @rect.shrink([20, 10])
rect.should == CGRectMake(30, 110, 10, 0)
+ end
+ end
+
+ describe "#shrink_left" do
+ it "should work" do
+ rect = @rect.shrink_left(10)
+ rect.should == CGRectMake(10, 100, 40, 20)
+ end
+ end
+
+ describe "#shrink_right" do
+ it "should work" do
+ rect = @rect.shrink_right(10)
+ rect.should == CGRectMake(20, 100, 40, 20)
+ end
+ end
+
+ describe "#shrink_up" do
+ it "should work" do
+ rect = @rect.shrink_up(10)
+ rect.should == CGRectMake(10, 100, 50, 10)
+ end
+ end
+
+ describe "#shrink_down" do
+ it "should work" do
+ rect = @rect.shrink_down(10)
+ rect.should == CGRectMake(10, 110, 50, 10)
+ end
+ end
+
+ describe "#shrink_width" do
+ # @rect = CGRect.make(x: 10, y: 100, width: 50, height: 20)
+ it "should work" do
+ rect = @rect.shrink_width(10)
+ rect.should == CGRectMake(20, 100, 30, 20)
+ end
+ end
+
+ describe "#shrink_height" do
+ it "should work" do
+ rect = @rect.shrink_height(10)
+ rect.should == CGRectMake(10, 110, 50, 0)
end
end
describe "#apply" do