Sha256: 89c2217ebbe8aacd79c0f2837d50dfe7e260eb9c6b4531bb84b72b698ebc72f5

Contents?: true

Size: 809 Bytes

Versions: 198

Compression:

Stored size: 809 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/patches/enumerator/stopped'

RSpec.describe ::Enumerator do
  let(:list) { %w[a b] }
  let(:instance) { list.each }

  it { expect(instance).to be_a(described_class) }
  it { expect(instance.peek).to eq('a') }
  it { expect(instance).to be_ongoing }
  it { expect(instance).not_to be_stopped }

  context 'with first next' do
    before { instance.next }

    it { expect(instance.peek).to eq('b') }
    it { expect(instance).to be_ongoing }
    it { expect(instance).not_to be_stopped }
  end

  context 'with last next' do
    before do
      instance.next
      instance.next
    end

    it { expect { instance.peek }.to raise_error(::StopIteration) }
    it { expect(instance).not_to be_ongoing }
    it { expect(instance).to be_stopped }
  end
end

Version data entries

198 entries across 198 versions & 3 rubygems

Version Path
eac_tools-0.41.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.40.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.39.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.38.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.37.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.37.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.37.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.36.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.36.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.35.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.34.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.33.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.32.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.31.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.31.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.30.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.29.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.28.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.27.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb
eac_tools-0.27.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb