Sha256: d57d229418edf6d59cca761bcf7a2c7b65190250ba05258c1d0a5139738eeff2

Contents?: true

Size: 462 Bytes

Versions: 5

Compression:

Stored size: 462 Bytes

Contents

require "spec_helper"
require "hamster/vector"

describe Hamster::Vector do
  describe "#count" do
    it "returns the number of elements" do
      V[:a, :b, :c].count.should == 3
    end

    it "returns the number of elements that equal the argument" do
      V[:a, :b, :b, :c].count(:b).should == 2
    end

    it "returns the number of element for which the block evaluates to true" do
      V[:a, :b, :c].count { |s| s != :b }.should == 2
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/vector/count_spec.rb
hamster-3.0.0 spec/lib/hamster/vector/count_spec.rb
hamster-2.0.0 spec/lib/hamster/vector/count_spec.rb
hamster-1.0.0 spec/lib/hamster/vector/count_spec.rb
hamster-1.0.1.pre.rc3 spec/lib/hamster/vector/count_spec.rb