require File.dirname(__FILE__) + "/../../spec_helper" describe Braintree::Xml::Rexml do describe "self.parse" do it "typecasts integers" do xml = "123" Braintree::Xml::Rexml.parse(xml).should == {"root"=>{"foo"=>{"__content__"=>"123", "type"=>"integer"}}} end it "works with dashes or underscores" do xml = <<-END END Braintree::Xml::Rexml.parse(xml).should == {"root"=>{"dash-es"=>{}, "under_scores"=>{}}} end it "uses nil if nil=true, otherwise uses empty string" do xml = <<-END END Braintree::Xml::Rexml.parse(xml).should == {"root"=>{"a_nil_value"=>{"nil"=>"true"}, "an_empty_string"=>{}}} end it "typecasts dates and times" do xml = <<-END 2009-10-28T10:19:49Z END Braintree::Xml::Rexml.parse(xml).should == {"root"=>{"created-at"=>{"__content__"=>"2009-10-28T10:19:49Z", "type"=>"datetime"}}} end it "builds an array if type=array" do xml = <<-END Adam Ben END Braintree::Xml::Rexml.parse(xml).should == {"root"=>{"customers"=>{"type"=>"array", "customer"=>[{"name"=>{"__content__"=>"Adam"}}, {"name"=>{"__content__"=>"Ben"}}]}}} end end end