Sha256: 28ec99a103a7919d92bce5b3943c409a47635ec1fb7810b9221a0643d461714f

Contents?: true

Size: 658 Bytes

Versions: 6

Compression:

Stored size: 658 Bytes

Contents

require File.dirname(__FILE__)+'/../abstract_unit'
require 'gorillib/hash/reverse_merge'

class HashReverseMergeTest < Test::Unit::TestCase

  def test_reverse_merge
    defaults = { :a => "x", :b => "y", :c => 10 }.freeze
    options  = { :a => 1, :b => 2 }
    expected = { :a => 1, :b => 2, :c => 10 }

    # Should merge defaults into options, creating a new hash.
    assert_equal expected, options.reverse_merge(defaults)
    assert_not_equal expected, options

    # Should merge! defaults into options, replacing options.
    merged = options.dup
    assert_equal expected, merged.reverse_merge!(defaults)
    assert_equal expected, merged
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gorillib-0.0.7 test/hash/reverse_merge_test.rb
gorillib-0.0.6 test/hash/reverse_merge_test.rb
gorillib-0.0.5 test/hash/reverse_merge_test.rb
gorillib-0.0.4 test/hash/reverse_merge_test.rb
gorillib-0.0.3 test/hash/reverse_merge_test.rb
gorillib-0.0.2 test/hash/reverse_merge_test.rb