Sha256: a505dcc5ea21ff6f1b99c15c63ece533f11116a1376c400d9b480f5fcee141b7

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"
require "hamster/list"

describe Hamster::List do
  [:group_by, :group].each do |method|
    describe "##{method}" do
      context "on a really big list" do
        it "doesn't run out of stack" do
          -> { Hamster.interval(0, STACK_OVERFLOW_DEPTH).send(method) }.should_not raise_error
        end
      end

      context "with a block" do
        [
          [[], []],
          [[1], [true => L[1]]],
          [[1, 2, 3, 4], [true => L[3, 1], false => L[4, 2]]],
        ].each do |values, expected|
          context "on #{values.inspect}" do
            it "returns #{expected.inspect}" do
              L[*values].send(method, &:odd?).should eql(H[*expected])
            end
          end
        end
      end

      context "without a block" do
        [
          [[], []],
          [[1], [1 => L[1]]],
          [[1, 2, 3, 4], [1 => L[1], 2 => L[2], 3 => L[3], 4 => L[4]]],
        ].each do |values, expected|
          context "on #{values.inspect}" do
            it "returns #{expected.inspect}" do
              L[*values].send(method).should eql(H[*expected])
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/list/group_by_spec.rb
hamster-3.0.0 spec/lib/hamster/list/group_by_spec.rb
hamster-2.0.0 spec/lib/hamster/list/group_by_spec.rb