Sha256: 71ef3d6d5007a47623413906bbb3fef0ace3685874c7731105dcaeb3b50574f2

Contents?: true

Size: 858 Bytes

Versions: 7

Compression:

Stored size: 858 Bytes

Contents

require 'spec_helper'

require 'hamster/set'

describe Hamster::Set do

  describe "#count" do

    [
      [[], 0],
      [[1], 1],
      [[1, 2], 1],
      [[1, 2, 3], 2],
      [[1, 2, 3, 4], 2],
      [[1, 2, 3, 4, 5], 3],
    ].each do |values, expected|

      describe "on #{values.inspect}" do

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

        describe "with a block" do

          before do
            @result = @original.count(&:odd?)
          end

          it "returns #{expected.inspect}" do
            @result.should == expected
          end

        end

        describe "without a block" do

          before do
            @result = @original.count
          end

          it "returns length" do
            @result.should == @original.length
          end

        end

      end

    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hamster-0.4.3 spec/hamster/set/count_spec.rb
hamster-0.4.2 spec/hamster/set/count_spec.rb
hamster-0.4.0 spec/hamster/set/count_spec.rb
hamster-0.3.10 spec/hamster/set/count_spec.rb
hamster-0.3.9 spec/hamster/set/count_spec.rb
hamster-0.3.8 spec/hamster/set/count_spec.rb
hamster-0.3.7 spec/hamster/set/count_spec.rb