Sha256: a0524bddd44afd1ec50c0e8c990012d10a4c429dfc043036d3ec43e9fba24e7c

Contents?: true

Size: 821 Bytes

Versions: 7

Compression:

Stored size: 821 Bytes

Contents

require 'helper'

class TestHash < 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

  def test_to_query
    defaults = { :a => "x", :b => "y", :c => 10 }
    expected = "a=x&b=y&c=10".split('&').sort
    actual = defaults.to_query.split('&').sort

    assert defaults.to_query.is_a?(String)
    assert_equal expected, actual
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solusvm-1.0.0.beta3 test/test_hash.rb
solusvm-1.0.0.beta2 test/test_hash.rb
solusvm-1.0.0.beta test/test_hash.rb
solusvm-0.10.1 test/test_hash.rb
solusvm-0.10.0 test/test_hash.rb
solusvm-0.9.0 test/test_hash.rb
solusvm-0.8.1 test/test_hash.rb