Sha256: 320123bf33e2cd2b21c67cc1f993db43ee1db20d50faa79feddfaba075079f20

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

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

describe Hamster::List do

  describe "#reject" do

    [
      [[], []],
      [["A"], ["A"]],
      [["A", "B", "C"], ["A", "B", "C"]],
      [["A", "b", "C"], ["A", "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.reject { |item| item == item.downcase }.should == Hamster.list(*result)
          end

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

        end

        describe "without a block" do

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

        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.1.12 spec/hamster/list/reject_spec.rb
hamster-0.1.11 spec/hamster/list/reject_spec.rb