Sha256: cfc4da2a48401e275608a14f4cbebab52923ef239849a473a2241f3b0758614e
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
require File.join(File.dirname(__FILE__), "..", "helper") class HashToXmlTest < Test::Unit::TestCase context "Calling hash_to_xml" do setup { ApricotEatsGorilla.sort_keys = true } context "with a Hash consisting of a single key-value-pair" do should "returns an XML String containing one node and a value" do hash = { "apricot" => "eats gorilla" } expected = "<apricot>eats gorilla</apricot>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end end context "with a Hash containing another Hash" do should "returns an XML String representing the given structure" do hash = { "apricot" => { "eats" => "gorilla", "drinks" => "beer" } } expected = "<apricot><drinks>beer</drinks><eats>gorilla</eats></apricot>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end end context "with a Hash containing a Hash containing an Array" do should "returns an XML String representing the given structure" do hash = { "apricot" => { "eats" => [ "gorilla", "snake" ] } } expected = "<apricot><eats>gorilla</eats><eats>snake</eats></apricot>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end end context "with a Hash containing a Hash containing an Array containing a Hash" do should "returns an XML String representing the given structure" do hash = { "apricot" => { "eats" => [ { "lotsOf" => "gorillas" }, { "justSome" => "snakes" } ] } } expected = "<apricot><eats><lotsOf>gorillas</lotsOf></eats>" << "<eats><justSome>snakes</justSome></eats></apricot>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smacks-apricoteatsgorilla-0.3.6 | test/apricoteatsgorilla/hash_to_xml_test.rb |
smacks-apricoteatsgorilla-0.3.61 | test/apricoteatsgorilla/hash_to_xml_test.rb |