Sha256: e98810330d24a8a429f5a837bae8bb7d8e282148a77bedf60189b19559309c02

Contents?: true

Size: 706 Bytes

Versions: 29

Compression:

Stored size: 706 Bytes

Contents

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

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

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

  it "returns true if the key is nil" do
    {nil => 'b'}.include?(nil).should == true
    {nil => nil}.include?(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/include_spec.rb
opal-0.4.3 spec/rubyspec/core/hash/include_spec.rb
opal-0.4.2 spec/rubyspec/core/hash/include_spec.rb
opal-0.4.1 spec/rubyspec/core/hash/include_spec.rb
opal-0.4.0 spec/rubyspec/core/hash/include_spec.rb
opal-0.3.44 spec/rubyspec/core/hash/include_spec.rb
opal-0.3.43 spec/rubyspec/core/hash/include_spec.rb
opal-0.3.42 spec/core/hash/include_spec.rb
opal-0.3.41 spec/core/hash/include_spec.rb
opal-0.3.40 spec/core/hash/include_spec.rb
opal-0.3.39 spec/core/hash/include_spec.rb
opal-0.3.38 spec/core/hash/include_spec.rb
opal-0.3.37 spec/core/hash/include_spec.rb
opal-0.3.36 spec/core/hash/include_spec.rb
opal-0.3.35 spec/core/hash/include_spec.rb
opal-0.3.34 spec/core/hash/include_spec.rb
opal-0.3.33 spec/core/hash/include_spec.rb
opal-0.3.32 spec/core/hash/include_spec.rb
opal-0.3.31 spec/core/hash/include_spec.rb
opal-0.3.30 spec/core/hash/include_spec.rb