Sha256: 16a723b0907815eec4af41c60fb155d64003af80f798ef9edff8e05aeb321fc6

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

require "spec_helper"

require "hamster/list"

describe Hamster::List do

  [:cons, :>>].each do |method|

    describe "##{method}" do

      [
        [[], "A", ["A"]],
        [["A"], "B", %w[B A]],
        [["A"], "A", %w[A A]],
        [%w[A B C], "D", %w[D A B C]],
      ].each do |values, new_value, expected|

        describe "on #{values.inspect} with #{new_value.inspect}" do

          before do
            @original = Hamster.list(*values)
            @result = @original.send(method, new_value)
          end

          it "preserves the original" do
            @original.should == Hamster.list(*values)
          end

          it "returns #{expected.inspect}" do
            @result.should == Hamster.list(*expected)
          end

        end

      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/cons_spec.rb