Sha256: 89acbfb223dae96498c2c766d09ab6adb55eb39f8fee2bc9807aa4cd2860f128

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

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

require 'hamster/hash'

describe Hamster::Hash do

  describe "#none?" do

    describe "when empty" do

      before do
        @hash = Hamster.hash
      end

      it "with a block returns true" do
        @hash.none? {}.should == true
      end

      it "with no block returns true" do
        @hash.none?.should == true
      end

    end

    describe "when not empty" do

      before do
        @hash = Hamster.hash("A" => "aye", "B" => "bee", "C" => "see", nil => "NIL")
      end

      describe "with a block" do

        [
          ["A", "aye"],
          ["B", "bee"],
          ["C", "see"],
          [nil, "NIL"],
        ].each do |pair|

          it "returns false if the block ever returns true (#{pair.inspect})" do
            @hash.none? { |key, value| key == pair.first && value == pair.last }.should == false
          end

          it "returns true if the block always returns false" do
            @hash.none? { |key, value| key == "D" && value == "dee" }.should == true
          end

        end

      end

      describe "with no block" do

        it "returns false" do
          @hash.none?.should == false
        end

      end

    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hamster-0.3.6 spec/hamster/hash/none_spec.rb
hamster-0.3.5 spec/hamster/hash/none_spec.rb
hamster-0.3.4 spec/hamster/hash/none_spec.rb
hamster-0.3.3 spec/hamster/hash/none_spec.rb
hamster-0.3.2 spec/hamster/hash/none_spec.rb
hamster-0.3.1 spec/hamster/hash/none_spec.rb
hamster-0.3.0 spec/hamster/hash/none_spec.rb
hamster-0.2.13 spec/hamster/hash/none_spec.rb
hamster-0.2.12 spec/hamster/hash/none_spec.rb
hamster-0.2.11 spec/hamster/hash/none_spec.rb
hamster-0.2.9 spec/hamster/hash/none_spec.rb
hamster-0.2.8 spec/hamster/hash/none_spec.rb