Sha256: fc4e435c5e9c37b94dbc5869c3b6f58858d1ac7ff2f5403d7f2f3600bdce8721

Contents?: true

Size: 535 Bytes

Versions: 13

Compression:

Stored size: 535 Bytes

Contents

require_relative '../../test_helper'

DuckPuncher.punch! Hash

class HashTest < MiniTest::Test
  def setup
    @subject = { a: 1, b: { c: 2 } }
  end

  def test_dig
    assert_equal @subject.dig(:a), 1
    assert_equal @subject.dig(:b, :a), nil
    assert_equal @subject.dig(:b, :c), 2
    assert_equal @subject.dig(:b), { c: 2 }
  end

  def test_compact
    assert_equal @subject.compact, { a: 1, b: { c: 2 } }
    @subject[:b] = nil
    assert_equal @subject, { a: 1, b: nil }
    assert_equal @subject.compact, { a: 1 }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
duck_puncher-4.5.1 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.5.0 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.4.2 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.4.1 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.4.0 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.3.1 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.3.0 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.2.3 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.2.2 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.2.1 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.2.0 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.1.0 test/lib/duck_puncher/hash_test.rb
duck_puncher-4.0.0 test/lib/duck_puncher/hash_test.rb