Sha256: 8f07c8451522f122117bded004ad07ebbe630c5d221385f5e641a6844a9ae698
Contents?: true
Size: 846 Bytes
Versions: 9
Compression:
Stored size: 846 Bytes
Contents
require File.dirname(__FILE__) + '/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
9 entries across 9 versions & 1 rubygems