Sha256: 3c96cc2289645390d81939236f6d3f680b0658bd4c77b07b46f04f34fb45d9e5

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')

class TestClass < Test::Unit::TestCase
  def test_indiferent_hash
    a = {:a => 1, "b" => 2}
    a.extend IndiferentHash

    assert_equal 1, a[:a]
    assert_equal 1, a["a"]
    assert_equal 2, a["b"]
    assert_equal 2, a[:b]
  end

  def test_case_insensitive_hash
    a = {:a => 1, "b" => 2}
    a.extend CaseInsensitiveHash

    assert_equal 1, a[:a]
    assert_equal 1, a["A"]
    assert_equal 1, a[:A]
    assert_equal 2, a["B"]
    assert_equal 2, a[:b]
  end

  def test_deep_merge
    o = {h: {a: 1, b: 2}}
    n = {h: {c: 3}}

    IndiferentHash.setup(o)
    o = o.deep_merge(n)

    assert_equal 1, o[:h]["a"]
    assert_equal 3, o[:h]["c"]
  end

  def test_except
    h = {:a => 1, "b" => 2}
    IndiferentHash.setup(h)
    assert_equal [:a], h.except(:b).keys
    assert_equal ["b"], h.except("a").keys
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scout-essentials-1.6.5 test/scout/test_indiferent_hash.rb