Sha256: f85fb1f505591f74ba4cbad48d75cbf0d255387aa53a2c8424fe57c929c686c0

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Parallel::Source::Array do
  subject { described_class.new(payloads) }

  let(:payloads) { %i[a b c] }

  describe '#next' do
    def job(**attributes)
      Mutant::Parallel::Source::Job.new(attributes)
    end

    def apply
      subject.next
    end

    context 'when there is a next job' do
      it 'returns that job' do
        expect(apply).to eql(job(index: 0, payload: :a))
      end

      it 'does not return the same job twice' do
        expect(apply).to eql(job(index: 0, payload: :a))
        expect(apply).to eql(job(index: 1, payload: :b))
        expect(apply).to eql(job(index: 2, payload: :c))
      end
    end

    context 'when there is no next job' do
      let(:payloads) { [] }

      it 'raises error' do
        expect { apply }.to raise_error(Mutant::Parallel::Source::NoJobError)
      end
    end
  end

  describe '#next?' do
    def apply
      subject.next?
    end

    context 'when there is a next job' do
      it 'returns true' do
        expect(apply).to be(true)
      end
    end

    context 'when there is no next job' do
      let(:payloads) { [] }

      it 'returns false' do
        expect(apply).to be(false)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.10 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.9 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.8 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.7 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.6 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.5 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.4 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.3 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.2 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.1 spec/unit/mutant/parallel/source/array_spec.rb
mutant-0.9.0 spec/unit/mutant/parallel/source/array_spec.rb