Sha256: 9738fb6cab69af1fa849bd7869f4b48bfbc357cb681a006c4dbdc7ad804993da

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'hamster/list'

describe Hamster::List do

  describe "#cadr" do

    [
      [[], :car, nil],
      [["A"], :car, "A"],
      [["A", "B", "C"], :car, "A"],
      [["A", "B", "C"], :cadr, "B"],
      [["A", "B", "C"], :caddr, "C"],
      [["A", "B", "C"], :cadddr, nil],
      [["A", "B", "C"], :caddddr, nil],
      [[], :cdr, Hamster.list],
      [["A"], :cdr, Hamster.list],
      [["A", "B", "C"], :cdr, Hamster.list("B", "C")],
      [["A", "B", "C"], :cddr, Hamster.list("C")],
      [["A", "B", "C"], :cdddr, Hamster.list],
      [["A", "B", "C"], :cddddr, Hamster.list],
    ].each do |values, method, expected|

      describe "on #{values.inspect}" do

        before do
          @list = Hamster.list(*values)
        end

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

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.19 spec/hamster/list/cadr_spec.rb
hamster-0.1.18 spec/hamster/list/cadr_spec.rb
hamster-0.1.17 spec/hamster/list/cadr_spec.rb
hamster-0.1.16 spec/hamster/list/cadr_spec.rb