Skip to content
This repository
Browse code

Removed Hash#from_xml method from HTTParty and added regression spec …

…to make sure HTTParty doesn't foobar ActiveSupport.
  • Loading branch information...
commit fc44b0b75a8ed321bc7f89f6dfa54fcae24b4723 1 parent 8591270
John Nunemaker authored December 08, 2008
6  lib/core_extensions.rb
@@ -285,11 +285,7 @@ def self.from_xml(xml)
285 285
   end
286 286
 end
287 287
 
288  
-class Hash
289  
-  def self.from_xml(xml)
290  
-    ToHashParser.from_xml(xml)
291  
-  end
292  
-  
  288
+class Hash  
293 289
   # @return <String> This hash as a query string
294 290
   #
295 291
   # @example
2  lib/httparty/request.rb
@@ -95,7 +95,7 @@ def parse_response(body) #:nodoc:
95 95
         return nil if body.nil? or body.empty?
96 96
         case format
97 97
         when :xml
98  
-          Hash.from_xml(body)
  98
+          ToHashParser.from_xml(body)
99 99
         when :json
100 100
           JSON.parse(body)
101 101
         else
16  spec/as_buggery_spec.rb
... ...
@@ -0,0 +1,16 @@
  1
+require File.join(File.dirname(__FILE__), 'spec_helper')
  2
+
  3
+require 'activesupport'
  4
+
  5
+describe Hash do
  6
+  describe "#from_xml" do
  7
+    it "should be able to convert xml with datetimes" do
  8
+      xml =<<EOL
  9
+<?xml version="1.0" encoding="UTF-8"?>
  10
+<created-at type="datetime">2008-12-01T20:00:00-05:00</created-at>
  11
+EOL
  12
+      hsh = Hash.from_xml(xml)
  13
+      hsh["created_at"].should == Time.parse("December 01st, 2008 20:00:00")
  14
+    end
  15
+  end
  16
+end

0 notes on commit fc44b0b

Please sign in to comment.
Something went wrong with that request. Please try again.