Sha256: 6416869a62258cfe860ba350e952563b09429f3eab0c5d48ce99f07671890633
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
require 'test_helper' require 'aws/core/util' describe AWS::Util do describe "#build_xml_from" do it "takes a hash and builds XML" do response = AWS::Util.build_xml_from :RootNode => { :InnerNode => "Value" } response.must_equal <<END <?xml version="1.0" encoding="UTF-8"?> <RootNode> <InnerNode>Value</InnerNode> </RootNode> END end it "will add namespace to the root node" do response = AWS::Util.build_xml_from( {:RootNode => { :InnerNode => "Value" }}, "http://cloudfront.amazonaws.com/doc/2010-11-01/" ) response.must_equal <<END <?xml version="1.0" encoding="UTF-8"?> <RootNode xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/"> <InnerNode>Value</InnerNode> </RootNode> END end it "works with arrays of items" do response = AWS::Util.build_xml_from( {:RootNode => { :InnerNode => ["Value1", "Value2", "Value3"] }} ) response.must_equal <<END <?xml version="1.0" encoding="UTF-8"?> <RootNode> <InnerNode>Value1</InnerNode> <InnerNode>Value2</InnerNode> <InnerNode>Value3</InnerNode> </RootNode> END end it "works at any nestedness of hashes" do response = AWS::Util.build_xml_from( :RootNode => { :InnerNode => [ {:Child => "Value1"}, {:Child => "Value2"} ] } ) response.must_equal <<END <?xml version="1.0" encoding="UTF-8"?> <RootNode> <InnerNode> <Child>Value1</Child> </InnerNode> <InnerNode> <Child>Value2</Child> </InnerNode> </RootNode> END end it "auto-strings all leaf nodes" do response = AWS::Util.build_xml_from( :RootNode => { :BoolVal => true, :Number => 12, :BadBool => false } ) response.must_equal <<END <?xml version="1.0" encoding="UTF-8"?> <RootNode> <BoolVal>true</BoolVal> <Number>12</Number> <BadBool>false</BadBool> </RootNode> END end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_aws-0.0.1d | test/aws/core/util_test.rb |