Sha256: 41b452cb94f6685f7a69bb854adbaa41f785d1a97ad543d78e646e588db1a4b6

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

describe SlowEnumeratorTools::Batcher do
  let(:wrapped) do
    Enumerator.new do |y|
      5.times do |i|
        y << i
        sleep 0.2
      end
    end
  end

  subject do
    described_class.batch(wrapped)
  end

  example do
    expect(subject.next).to eq([0])
  end

  example do
    subject.next
    expect(subject.next).to eq([1])
  end

  example do
    subject
    sleep 0.25
    expect(subject.next).to eq([0, 1])
  end

  example do
    subject
    sleep 0.45
    expect(subject.next).to eq([0, 1, 2])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slow_enumerator_tools-1.0.0 spec/batcher_spec.rb