Sha256: 5e3a270855a882bada4d0764fa21f9edb404469e2266a6341111662db6ba129e

Contents?: true

Size: 706 Bytes

Versions: 29

Compression:

Stored size: 706 Bytes

Contents

describe "Hash#has_key?" do
  it "returns true if the argument is a key" do
    h = {:a => 1, :b => 2, :c => 3, 4 => 0}
    h.has_key?(:a).should == true
    h.has_key?(:b).should == true
    h.has_key?(:B).should == false
    h.has_key?(2).should == false
    h.has_key?(4).should == true
    h.has_key?(42).should == false
  end

  it "returns true if the key's matching value was nil" do
    {:xyz => nil}.has_key?(:xyz).should == true
  end

  it "returns true if the key's matching value was false" do
    {:xyz => false}.has_key?(:xyz).should == true
  end

  it "returns true if the key is nil" do
    {nil => 'b'}.has_key?(nil).should == true
    {nil => nil}.has_key?(nil).should == true
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.4.3 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.4.2 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.4.1 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.4.0 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.3.44 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.3.43 spec/rubyspec/core/hash/has_key_spec.rb
opal-0.3.42 spec/core/hash/has_key_spec.rb
opal-0.3.41 spec/core/hash/has_key_spec.rb
opal-0.3.40 spec/core/hash/has_key_spec.rb
opal-0.3.39 spec/core/hash/has_key_spec.rb
opal-0.3.38 spec/core/hash/has_key_spec.rb
opal-0.3.37 spec/core/hash/has_key_spec.rb
opal-0.3.36 spec/core/hash/has_key_spec.rb
opal-0.3.35 spec/core/hash/has_key_spec.rb
opal-0.3.34 spec/core/hash/has_key_spec.rb
opal-0.3.33 spec/core/hash/has_key_spec.rb
opal-0.3.32 spec/core/hash/has_key_spec.rb
opal-0.3.31 spec/core/hash/has_key_spec.rb
opal-0.3.30 spec/core/hash/has_key_spec.rb