Sha256: d1f4afb6617a35e9cff35b5607b3360bb74fcd2d3544370a071d701895d8a3f5
Contents?: true
Size: 1.46 KB
Versions: 3
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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hamster-0.4.3 | spec/hamster/hash/put_spec.rb |
hamster-0.4.2 | spec/hamster/hash/put_spec.rb |
hamster-0.4.0 | spec/hamster/hash/put_spec.rb |