Skip to content

Commit

Permalink
Fix test to reflect use of to_param for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
brainopia committed Sep 18, 2011
1 parent 51bef9d commit 8e3d267
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions activesupport/test/core_ext/hash_ext_test.rb
Expand Up @@ -9,7 +9,7 @@
class HashExtTest < Test::Unit::TestCase class HashExtTest < Test::Unit::TestCase
class IndifferentHash < HashWithIndifferentAccess class IndifferentHash < HashWithIndifferentAccess
end end

class SubclassingArray < Array class SubclassingArray < Array
end end


Expand Down Expand Up @@ -272,14 +272,14 @@ def test_indifferent_hash_with_array_of_hashes
hash = { "urls" => { "url" => [ { "address" => "1" }, { "address" => "2" } ] }}.with_indifferent_access hash = { "urls" => { "url" => [ { "address" => "1" }, { "address" => "2" } ] }}.with_indifferent_access
assert_equal "1", hash[:urls][:url].first[:address] assert_equal "1", hash[:urls][:url].first[:address]
end end

def test_should_preserve_array_subclass_when_value_is_array def test_should_preserve_array_subclass_when_value_is_array
array = SubclassingArray.new array = SubclassingArray.new
array << { "address" => "1" } array << { "address" => "1" }
hash = { "urls" => { "url" => array }}.with_indifferent_access hash = { "urls" => { "url" => array }}.with_indifferent_access
assert_equal SubclassingArray, hash[:urls][:url].class assert_equal SubclassingArray, hash[:urls][:url].class
end end

def test_should_preserve_array_class_when_hash_value_is_frozen_array def test_should_preserve_array_class_when_hash_value_is_frozen_array
array = SubclassingArray.new array = SubclassingArray.new
array << { "address" => "1" } array << { "address" => "1" }
Expand Down Expand Up @@ -543,7 +543,7 @@ def test_number_hash
end end


def test_to_param_hash def test_to_param_hash
assert_equal 'custom2=param2-1&custom=param-1', {ToParam.new('custom') => ToParam.new('param'), ToParam.new('custom2') => ToParam.new('param2')}.to_param assert_equal 'custom-1=param-1&custom2-1=param2-1', {ToParam.new('custom') => ToParam.new('param'), ToParam.new('custom2') => ToParam.new('param2')}.to_param
end end


def test_to_param_hash_escapes_its_keys_and_values def test_to_param_hash_escapes_its_keys_and_values
Expand Down Expand Up @@ -955,13 +955,13 @@ def test_tag_with_attrs_and_whitespace
hash = Hash.from_xml(xml) hash = Hash.from_xml(xml)
assert_equal "bacon is the best", hash['blog']['name'] assert_equal "bacon is the best", hash['blog']['name']
end end

def test_empty_cdata_from_xml def test_empty_cdata_from_xml
xml = "<data><![CDATA[]]></data>" xml = "<data><![CDATA[]]></data>"

assert_equal "", Hash.from_xml(xml)["data"] assert_equal "", Hash.from_xml(xml)["data"]
end end

def test_xsd_like_types_from_xml def test_xsd_like_types_from_xml
bacon_xml = <<-EOT bacon_xml = <<-EOT
<bacon> <bacon>
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def test_type_trickles_through_when_unknown


assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"] assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"]
end end

def test_should_use_default_value_for_unknown_key def test_should_use_default_value_for_unknown_key
hash_wia = HashWithIndifferentAccess.new(3) hash_wia = HashWithIndifferentAccess.new(3)
assert_equal 3, hash_wia[:new_key] assert_equal 3, hash_wia[:new_key]
Expand Down

0 comments on commit 8e3d267

Please sign in to comment.