Sha256: 8a2fcc1047c5771c71f4de7799309e5a6cc3132b622ebd004ea9fe7dc83bb395

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

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

describe Hamster::List do

  describe "#map" do

    [
      [[], []],
      [["A"], ["a"]],
      [["A", "B", "C"], ["a", "b", "c"]],
    ].each do |values, result|

      describe "on #{values.inspect}" do

        list = Hamster.list(*values)

        describe "with a block" do

          it "returns #{result}" do
            list.map { |item| item.downcase }.should == Hamster.list(*result)
          end

          it "is lazy" do
            count = 0
            list.map { |item| count += 1 }
            count.should <= 1
          end

        end

        describe "without a block" do

          it "returns self" do
            list.map.should == list
          end

        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-0.1.11 spec/hamster/list/map_spec.rb