Sha256: 5d8bc6f58a16747faf08e46db5f96cf4c1aefb0c178ec0a369064cfd8799eab4

Contents?: true

Size: 508 Bytes

Versions: 14

Compression:

Stored size: 508 Bytes

Contents

# encoding: utf-8

class Nanoc::ExtraCoreExtEnumerableTest < Nanoc::TestCase

  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

14 entries across 14 versions & 1 rubygems

Version Path
nanoc-3.7.3 test/extra/core_ext/test_enumerable.rb
nanoc-3.7.2 test/extra/core_ext/test_enumerable.rb
nanoc-3.7.1 test/extra/core_ext/test_enumerable.rb
nanoc-3.7.0 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.11 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.10 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.9 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.8 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.7 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.6 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.5 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.4 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.3 test/extra/core_ext/test_enumerable.rb
nanoc-3.6.2 test/extra/core_ext/test_enumerable.rb