Sha256: eb5d3af66e7c58de7af84380f0ab9868a6020131df7c2ecb9e40ed1a0c6ebcc4
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Hamster::Hash do describe "#each" do before do @hash = Hamster::Hash.new @expected_pairs = { "A" => "aye", "B" => "bee", "C" => "sea" } @expected_pairs.each do |key, value| @hash = @hash.put(key, value) end end describe "with a block (internal iteration)" do it "returns self" do @hash.each {}.should equal(@hash) end it "yields all key value pairs" do actual_pairs = {} @hash.each do |key, value| actual_pairs[key] = value end actual_pairs.should == @expected_pairs end end describe "with no block (external iteration)" do it "returns an enumerator over all key value pairs" do actual_pairs = {} enum = @hash.each loop do key, value = enum.next actual_pairs[key] = value end actual_pairs.should == @expected_pairs end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.1.8 | spec/hamster/hash/each_spec.rb |
hamster-0.1.7 | spec/hamster/hash/each_spec.rb |
hamster-0.1.6 | spec/hamster/hash/each_spec.rb |
hamster-0.1.5 | spec/hamster/hash/each_spec.rb |