Sha256: b082ead51c0aea2047579cbeb1bd01612d589c7789917411679e9f1c41055bde

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

require "spec_helper"
require "hamster/list"

describe Hamster::List do
  [:to_a, :entries].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).to_a }.should_not raise_error
        end
      end

      [
        [],
        ["A"],
        %w[A B C],
      ].each do |values|
        context "on #{values.inspect}" do
          let(:list) { L[*values] }

          it "returns #{values.inspect}" do
            list.send(method).should == values
          end

          it "leaves the original unchanged" do
            list.send(method)
            list.should eql(L[*values])
          end

          it "returns a mutable array" do
            result = list.send(method)
            expect(result.last).to_not eq("The End")
            result << "The End"
            result.last.should == "The 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/to_a_spec.rb
hamster-3.0.0 spec/lib/hamster/list/to_a_spec.rb
hamster-2.0.0 spec/lib/hamster/list/to_a_spec.rb