6 describe "#in_groups_of" do
7 it "should correctly group array members" do
8 [1,2,3,4,5,6,7,8,9,10].in_groups_of(5).should == [[1,2,3,4,5], [6,7,8,9,10]]
11 it "should padd missing data with correctly" do
12 arr = [1,2,3,4,5,6,7,8,9,10]
14 arr.in_groups_of(3).should == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, nil, nil]]
15 arr.in_groups_of(3, 0).should == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 0, 0]]
16 arr.in_groups_of(11).should == [[1,2,3,4,5, 6,7,8,9,10, nil]]
17 arr.in_groups_of(11, 0).should == [[1,2,3,4,5, 6,7,8,9,10, 0]]
20 it "should indicate when the last abtched was reached" do
21 arr = [1,2,3,4,5,6,7,8,9,10]
25 [1,2,3,4,5,6,7,8,9,10].in_groups_of(3) {|a, last_batch| ctr += 1 unless last_batch}