Sha256: 88e8c6760a1ed4d73b3c1ae838e4e80b4ef3b0aa574bfd5e68bcdcd31286bf31

Contents?: true

Size: 572 Bytes

Versions: 3

Compression:

Stored size: 572 Bytes

Contents

# encoding: utf-8

require 'test/helper'

class Nanoc3::ExtraCoreExtEnumerableTest < MiniTest::Unit::TestCase

  include Nanoc3::TestHelpers

  class MyCollection

    include Enumerable

    def initialize(array)
      @array = array
    end

    def each(&block)
      @array.each { |i| block.call(i) }
    end

  end

  def test_group_by
    input = MyCollection.new([ 'foo', 'bar', 'baz' ])

    output_expected = { ?f => [ 'foo' ], ?b => [ 'bar', 'baz' ] }
    output_actual   = input.group_by { |i| i[0] }

    assert_equal output_expected, output_actual
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc3-3.1.9 test/extra/core_ext/test_enumerable.rb
nanoc3-3.1.8 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.0a4 test/extra/core_ext/test_enumerable.rb