Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@takeshy
Created November 12, 2011 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeshy/1360816 to your computer and use it in GitHub Desktop.
Save takeshy/1360816 to your computer and use it in GitHub Desktop.
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