1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Use MultiXML and MultiJSON for parsing instead of Crack

This commit is contained in:
Brennan Frydl 2011-07-07 10:29:02 -04:00
parent 2d2856bfee
commit 05cacfee9e
4 changed files with 10 additions and 6 deletions

View file

@ -13,6 +13,8 @@ Gem::Specification.new do |s|
s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
s.add_dependency 'crack', HTTParty::CRACK_DEPENDENCY
s.add_dependency 'multi_json'
s.add_dependency 'multi_xml'
s.add_development_dependency "activesupport", "~> 2.3"
s.add_development_dependency "cucumber", "~> 0.7"

View file

@ -4,6 +4,8 @@ require 'net/https'
require 'uri'
require 'zlib'
require 'crack'
require 'multi_xml'
require 'multi_json'
require 'httparty/module_inheritable_attributes'
require 'httparty/cookie_hash'

View file

@ -109,11 +109,11 @@ module HTTParty
protected
def xml
Crack::XML.parse(body)
MultiXml.parse(body)
end
def json
Crack::JSON.parse(body)
MultiJson.decode(body)
end
def yaml

View file

@ -129,13 +129,13 @@ describe HTTParty::Parser do
HTTParty::Parser.new('body', nil)
end
it "parses xml with Crack" do
Crack::XML.should_receive(:parse).with('body')
it "parses xml with MultiXml" do
MultiXml.should_receive(:parse).with('body')
subject.send(:xml)
end
it "parses json with Crack" do
Crack::JSON.should_receive(:parse).with('body')
it "parses json with MultiJson" do
MultiJson.should_receive(:decode).with('body')
subject.send(:json)
end