require 'test_helper' require 'simple_aws/core/util' describe SimpleAWS::Util do describe "#build_xml_from" do it "takes a hash and builds XML" do response = SimpleAWS::Util.build_xml_from :RootNode => { :InnerNode => "Value" } response.must_equal < Value END end it "will add namespace to the root node" do response = SimpleAWS::Util.build_xml_from( {:RootNode => { :InnerNode => "Value" }}, "http://cloudfront.amazonaws.com/doc/2010-11-01/" ) response.must_equal < Value END end it "works with arrays of items" do response = SimpleAWS::Util.build_xml_from( {:RootNode => { :InnerNode => ["Value1", "Value2", "Value3"] }} ) response.must_equal < Value1 Value2 Value3 END end it "works at any nestedness of hashes" do response = SimpleAWS::Util.build_xml_from( :RootNode => { :InnerNode => [ {:Child => "Value1"}, {:Child => "Value2"} ] } ) response.must_equal < Value1 Value2 END end it "auto-strings all leaf nodes" do response = SimpleAWS::Util.build_xml_from( :RootNode => { :BoolVal => true, :Number => 12, :BadBool => false } ) response.must_match(%r{true}) response.must_match(%r{12}) response.must_match(%r{false}) end end end