Sha256: 7f0ca6c79f72960b7b008885a1652705f6d945241f07b5e13bbeacb19d11635a
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'hamster/hash' describe Hamster::Hash do [:reduce, :inject, :fold].each do |method| describe "##{method}" do describe "when empty" do before do @original = Hamster.hash @result = @original.send(method, "ABC") {} end it "returns the memo" do @result.should == "ABC" end end describe "when not empty" do before do @original = Hamster.hash("A" => "aye", "B" => "bee", "C" => "see") end describe "with a block" do before do @result = @original.send(method, 0) { |memo, key, value| memo + 1 } end it "returns the final memo" do @result.should == 3 end end describe "with no block" do before do @result = @original.send(method, "ABC") end it "returns the memo" do @result.should == "ABC" end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems