Created
November 12, 2011 17:01
-
-
Save takeshy/1360816 to your computer and use it in GitHub Desktop.
HashWithValueIndifferentAccessのspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
require File.expand_path('../../hash_with_value_indifferent_access',__FILE__) | |
describe HashWithValueIndifferentAccess do | |
context "initialize" do | |
before do | |
@hash = HashWithValueIndifferentAccess.new({:a=>:b}) | |
end | |
it "symbole value compare string value " do | |
@hash[:a].should == "b" | |
end | |
it "symbole value compare simbol value" do | |
@hash[:a].should == :b | |
end | |
it "symbole values compare string value " do | |
@hash.values.should == ["b"] | |
end | |
it "symbole values compare simbol value" do | |
@hash.values.should == [:b] | |
end | |
end | |
context "update" do | |
before do | |
@hash = HashWithValueIndifferentAccess.new({:a=>:b}) | |
@hash[:c] = :d | |
end | |
it "symbole value compare string value " do | |
@hash[:c].should == "d" | |
end | |
it "symbole value compare simbol value" do | |
@hash[:c].should == :d | |
end | |
it "symbole values compare string value " do | |
@hash.values.sort.should == ["b","d"] | |
end | |
it "symbole values compare simbol value" do | |
@hash.values.sort.should == [:b,:d] | |
end | |
it "hash compare hash_with_value_indifferent_access " do | |
@hash.should == {:a=>:b,:c=>:d} | |
end | |
it "hash compare hash_with_value_indifferent_access " do | |
@hash.should == {:a=>"b",:c=>"d"} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment