Sha256: afdec520540ad501ff171679bdd341f52cb6ddc2407688acc20883dd8cea1f08

Contents?: true

Size: 755 Bytes

Versions: 4

Compression:

Stored size: 755 Bytes

Contents

require "spec_helper"
require "hamster/vector"

describe Hamster::Vector do
  let(:vector) { Hamster.vector(*values) }

  describe "#to_ary" do
    let(:values) { %w[A B C D] }

    it "converts using block parameters" do
      def expectations(&block)
        yield(vector)
      end
      expectations do |a, b, *c|
        expect(a).to eq("A")
        expect(b).to eq("B")
        expect(c).to eq(%w[C D])
      end
    end

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

    it "converts using splat" do
      array = *vector
      expect(array).to eq(%w[A B C D])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-1.0.0 spec/lib/hamster/vector/to_ary_spec.rb
hamster-1.0.1.pre.rc3 spec/lib/hamster/vector/to_ary_spec.rb
hamster-1.0.1.pre.rc2 spec/hamster/vector/to_ary_spec.rb
hamster-1.0.1.pre.rc.1 spec/hamster/vector/to_ary_spec.rb