Permalink
Browse files

Remove stray underscore from the hash conversion methods which broke …

…backwards compatibility with Hash.from_xml

Also add an all-caps test to prevent future regressions
  • Loading branch information...
1 parent 17e712d commit ebe8dd6108ab9b2ecd74bacf7fa128e9d4f28e4e codebrulee committed with NZKoz May 4, 2009
@@ -221,7 +221,7 @@ def unrename_keys(params)
case params.class.to_s
when "Hash"
params.inject({}) do |h,(k,v)|
- h[k.to_s.underscore.tr("-", "_")] = unrename_keys(v)
+ h[k.to_s.tr("-", "_")] = unrename_keys(v)
h
end
when "Array"
@@ -654,6 +654,22 @@ def test_empty_array_from_xml
assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
end
+ def test_all_caps_key_from_xml
+ test_xml = <<-EOT
+ <ABC3XYZ>
+ <TEST>Lorem Ipsum</TEST>
+ </ABC3XYZ>
+ EOT
+
+ expected_hash = {
+ "ABC3XYZ" => {
+ "TEST" => "Lorem Ipsum"
+ }
+ }
+
+ assert_equal expected_hash, Hash.from_xml(test_xml)
+ end
+
def test_empty_array_with_whitespace_from_xml
blog_xml = <<-XML
<blog>

0 comments on commit ebe8dd6

Please sign in to comment.