Sha256: 1086d5e485d050ae560599de10eb83760ea7d55e65e905347a148f61b01121c3

Contents?: true

Size: 549 Bytes

Versions: 8

Compression:

Stored size: 549 Bytes

Contents

# encoding: utf-8

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

8 entries across 8 versions & 1 rubygems

Version Path
nanoc3-3.2.4 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.3 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.2 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.1 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.0 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.0b3 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.0b2 test/extra/core_ext/test_enumerable.rb
nanoc3-3.2.0b1 test/extra/core_ext/test_enumerable.rb