Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
HashWithValueIndifferentAccessのspec
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