Sha256: 0d3879874ab7c1af4732f81177a039244d8d9fdb4adf66a58f500f1c31e30785

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

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

require 'hamster/set'

describe Hamster::Set do

  describe "#grep" do

    describe "without a block" do

      [
        [[], []],
        [["A"], ["A"]],
        [[1], []],
        [["A", 2, "C"], ["A", "C"]],
      ].each do |values, expected|

        describe "on #{values.inspect}" do

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

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

        end

      end

    end

    describe "with a block" do

      [
        [[], []],
        [["A"], ["a"]],
        [[1], []],
        [["A", 2, "C"], ["a", "c"]],
      ].each do |values, expected|

        describe "on #{values.inspect}" do

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

          it "returns #{expected.inspect}" do
            @list.grep(String) { |item| item.downcase }.should == Hamster.set(*expected)
          end


        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/set/grep_spec.rb
hamster-0.2.6 spec/hamster/set/grep_spec.rb