test/geometry/size.rb in geometry-6.2 vs test/geometry/size.rb in geometry-6.3

- old
+ new

@@ -39,16 +39,25 @@ assert_equal(3, size.x) assert_equal(4, size.y) end end - it "allow indexed element access" do - size = Geometry::Size[5,6] - assert_equal(2, size.size) - assert_equal(5, size[0]) - assert_equal(6, size[1]) + describe 'when array access' do + it 'must allow indexed access' do + size = Geometry::Size[5,6] + size.size.must_equal 2 + size[0].must_equal 5 + size[1].must_equal 6 + end + + it 'must slize with a start index and a length' do + size = Geometry::Size[5, 6, 7] + slice = size[1,2] + slice.length.must_equal 2 + end end + it "allow named element access" do size = Geometry::Size[5,6,7] assert_equal(3, size.size) assert_equal(5, size.x) assert_equal(6, size.y) @@ -97,27 +106,39 @@ assert_equal('Size[10, 11]', size.to_s) end it 'must inset with horizontal and vertical insets' do subject.inset(4).must_equal Geometry::Size[6, 6] - subject.inset(2,3).must_equal Geometry::Size[8, 7] - subject.inset(x:2, y:3).must_equal Geometry::Size[8, 7] + subject.inset(2,3).must_equal Geometry::Size[6, 4] + subject.inset(x:2, y:3).must_equal Geometry::Size[6, 4] + end + + it 'must inset with left and top' do subject.inset(left:2, top:3).must_equal Geometry::Size[8, 7] + end + + it 'must inset with right and bottom' do subject.inset(right:2, bottom:3).must_equal Geometry::Size[8, 7] end it 'must inset with insets for top, left, bottom, right' do subject.inset(top:1, left:2, bottom:3, right:4).must_equal Geometry::Size[4, 6] end it 'must outset' do subject.outset(4).must_equal Geometry::Size[14, 14] - subject.outset(2,3).must_equal Geometry::Size[12, 13] - subject.outset(x:2, y:3).must_equal Geometry::Size[12, 13] + subject.outset(2,3).must_equal Geometry::Size[14, 16] + subject.outset(x:2, y:3).must_equal Geometry::Size[14, 16] + end + + it 'must outset with left and top' do subject.outset(left:2, top:3).must_equal Geometry::Size[12, 13] + end + + it 'must outset with right and bottom' do subject.outset(right:2, bottom:3).must_equal Geometry::Size[12, 13] end - it 'must inset with insets for top, left, bottom, right' do + it 'must outset with insets for top, left, bottom, right' do subject.outset(top:1, left:2, bottom:3, right:4).must_equal Geometry::Size[16, 14] end end