0
@@ -99,7 +99,7 @@ class ArrayExtToSTests < Test::Unit::TestCase
0
class ArrayExtGroupingTests < Test::Unit::TestCase
0
- def test_
group_by_with_perfect_fit
0
+ def test_
in_groups_of_with_perfect_fit
0
('a'..'i').to_a.in_groups_of(3) do |group|
0
@@ -109,7 +109,7 @@ class ArrayExtGroupingTests < Test::Unit::TestCase
0
assert_equal [%w(a b c), %w(d e f), %w(g h i)], ('a'..'i').to_a.in_groups_of(3)
0
- def test_
group_by_with_padding
0
+ def test_
in_groups_of_with_padding
0
('a'..'g').to_a.in_groups_of(3) do |group|
0
@@ -118,7 +118,7 @@ class ArrayExtGroupingTests < Test::Unit::TestCase
0
assert_equal [%w(a b c), %w(d e f), ['g', nil, nil]], groups
0
- def test_
group_by_pads_with_specified_values
0
+ def test_
in_groups_of_pads_with_specified_values
0
('a'..'g').to_a.in_groups_of(3, 'foo') do |group|
0
@@ -128,7 +128,7 @@ class ArrayExtGroupingTests < Test::Unit::TestCase
0
assert_equal [%w(a b c), %w(d e f), ['g', 'foo', 'foo']], groups
0
- def test_
group_without_padding
0
+ def test_
in_groups_of_without_padding
0
('a'..'g').to_a.in_groups_of(3, false) do |group|
0
@@ -137,6 +137,48 @@ class ArrayExtGroupingTests < Test::Unit::TestCase
0
assert_equal [%w(a b c), %w(d e f), ['g']], groups
0
+ def test_in_groups_returned_array_size
0
+ 1.upto(array.size + 1) do |number|
0
+ assert_equal number, array.in_groups(number).size
0
+ def test_in_groups_with_empty_array
0
+ assert_equal [[], [], []], [].in_groups(3)
0
+ def test_in_groups_with_block
0
+ array.in_groups(3) do |group|
0
+ assert_equal array.in_groups(3), groups
0
+ def test_in_groups_with_perfect_fit
0
+ assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
0
+ (1..9).to_a.in_groups(3)
0
+ def test_in_groups_with_padding
0
+ assert_equal [[1, 2, 3], [4, 5, nil], [6, 7, nil]],
0
+ assert_equal [[1, 2, 3], [4, 5, 'foo'], [6, 7, 'foo']],
0
+ array.in_groups(3, 'foo')
0
+ def test_in_groups_without_padding
0
+ assert_equal [[1, 2, 3], [4, 5], [6, 7]],
0
+ (1..7).to_a.in_groups(3, false)
0
class ArraySplitTests < Test::Unit::TestCase
Seems like this could be simplified quite a bit. Here’s how we did it: http://github.com/collectiveidea/awesomeness/tree/master/lib/awesomeness/core_ext/enumerable.rb