Sha256: 719e67f92bc8505323ee9853ea8140f89ac6d9b8e9d154bae9e6ac4f9f491184
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Hamster::Hash do describe "#any?" do describe "when empty" do before do @hash = Hamster.hash end it "with a block returns false" do @hash.any? {}.should be_false end it "with no block returns false" do @hash.any?.should be_false 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 true if the block ever returns true (#{pair.inspect})" do @hash.any? { |key, value| key == pair.first && value == pair.last }.should be_true end it "returns false if the block always returns false" do @hash.any? { |key, value| key == "D" && value == "dee" }.should be_false end end end describe "with no block" do it "returns true" do @hash.any?.should be_true end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.1.11 | spec/hamster/hash/any_spec.rb |