Sha256: 515f57b2ca3e4048d11c13d98463648f2e8f9a431daf388714b1ca3c2f9ef1e9
Contents?: true
Size: 738 Bytes
Versions: 31
Compression:
Stored size: 738 Bytes
Contents
describe "Hash#assoc" do before(:each) do @h = {:apple => :green, :orange => :orange, :grape => :green, :banana => :yellow} end it "returns an Array is the argument is == to a key of the Hash" do @h.assoc(:apple).should be_kind_of(Array) end it "returns a 2-element Array if the argument is == to a key of the Hash" do @h.assoc(:grape).size.should == 2 end it "sets the first element of the Array to the located key" do @h.assoc(:banana).first.should == :banana end it "sets the last element of the Array to the value of the located key" do @h.assoc(:banana).last.should == :yellow end it "returns nil if the argument if not a key of the Hash" do @h.assoc(:green).should be_nil end end
Version data entries
31 entries across 31 versions & 1 rubygems