Sha256: b8e348adeae21af0660d07794ba32f2461ad57d85cbcede72bb2c4557fe2f16e

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

require "spec_helper"
require "hamster/list"

describe Hamster do
  describe "#cycle" do
    it "is lazy" do
      -> { Hamster.stream { fail }.cycle }.should_not raise_error
    end

    context "with an empty list" do
      it "returns an empty list" do
        L.empty.cycle.should be_empty
      end
    end

    context "with a non-empty list" do
      let(:list) { L["A", "B", "C"] }

      it "preserves the original" do
        list.cycle
        list.should == L["A", "B", "C"]
      end

      it "infinitely cycles through all values" do
        list.cycle.take(7).should == L["A", "B", "C", "A", "B", "C", "A"]
      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/cycle_spec.rb
hamster-3.0.0 spec/lib/hamster/list/cycle_spec.rb
hamster-2.0.0 spec/lib/hamster/list/cycle_spec.rb