Sha256: 4045e36823006f2b7eb201c1bd1161a5ff9254d91c48c8c3f668f5f47eb7d4a2

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

require "spec_helper"

require "hamster/list"

describe Hamster::List do
  let(:list) { Hamster.list("A", "B", "C", "D") }

  describe "#to_ary" do
    context "on a really big list" do
      let(:list) { Hamster.interval(0, STACK_OVERFLOW_DEPTH) }

      it "doesn't run out of stack" do
        -> { list.to_ary }.should_not raise_error
      end
    end

    context "enables implicit conversion to" do
      it "block parameters" do
        def func(&block)
          yield(list)
        end

        func do |a, b, *c|
          expect(a).to eq("A")
          expect(b).to eq("B")
          expect(c).to eq(%w[C D])
        end
      end

      it "method arguments" do
        def func(a, b, *c)
          expect(a).to eq("A")
          expect(b).to eq("B")
          expect(c).to eq(%w[C D])
        end
        func(*list)
      end

      it "works with splat" do
        array = *list
        expect(array).to eq(%w[A B C D])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc.1 spec/hamster/list/to_ary_spec.rb