Sha256: 9ba553ea74bfb2ab569153c55f8865cbd56221d0922ca205f5722a4c5f91dbf3
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Hamster::Hash do [:map, :collect].each do |method| describe "##{method}" do describe "when empty" do before do @original = Hamster.hash @mapped = @original.send(method) {} end it "returns self" do @mapped.should equal(@original) 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 @mapped = @original.send(method) { |key, value| [key.downcase, value.upcase] } end it "preserves the original values" do @original.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see") end it "returns a new hash with the mapped values" do @mapped.should == Hamster.hash("a" => "AYE", "b" => "BEE", "c" => "SEE") end end describe "with no block" do before do @result = @original.send(method) end it "returns self" do @result.should equal(@original) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.1.14 | spec/hamster/hash/map_spec.rb |
hamster-0.1.13 | spec/hamster/hash/map_spec.rb |
hamster-0.1.12 | spec/hamster/hash/map_spec.rb |