Sha256: c829624df7d8eabfbbcab0058af02f3894291e1054afa276e9ca1686eff7c6e5
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require "spec_helper" require "hamster/hash" describe Hamster::Hash do describe "#put" do before do @original = Hamster.hash("A" => "aye", "B" => "bee", "C" => "see") end describe "with a block" do it "passes the value to the block" do @original.put("A") { |value| value.should == "aye" } end it "replaces the value with the result of the block" do result = @original.put("A") { |value| "FLIBBLE" } result.get("A").should == "FLIBBLE" end it "supports to_proc methods" do result = @original.put("A", &:upcase) result.get("A").should == "AYE" end end describe "with a unique key" do before do @result = @original.put("D", "dee") end it "preserves the original" do @original.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see") end it "returns a copy with the superset of key/value pairs" do @result.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see", "D" => "dee") end end describe "with a duplicate key" do before do @result = @original.put("C", "sea") end it "preserves the original" do @original.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see") end it "returns a copy with the superset of key/value pairs" do @result.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "sea") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hamster-1.0.1.pre.rc.1 | spec/hamster/hash/put_spec.rb |