Sha256: 0c1abdc3beb00be6d267a760a40241d97418698b5ab5ee64fc281ef4f6339b36
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
# -*- coding: utf-8 -*- require 'test/unit' require File.join(File.dirname(__FILE__), "..", "lib", "apricoteatsgorilla") class HashToXmlTest < Test::Unit::TestCase def test_dead_simple hash = { "dude" => "likes beer" } expected = "<dude>likes beer</dude>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end def test_nested_hash hash = { "dude" => { "likes" => "beer", "hates" => "appletini" } } expected = "<dude><hates>appletini</hates><likes>beer</likes></dude>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end def test_nested_hash_with_array hash = { "dude" => { "likes" => [ "beer", "helicopters" ] } } expected = "<dude><likes>beer</likes><likes>helicopters</likes></dude>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end def test_nested_hash_with_array_containing_a_hash hash = { "dude" => { "likes" => [ { "beer" => "a lot" }, { "helicopters" => "a little more" } ] } } expected = "<dude><likes><beer>a lot</beer></likes><likes><helicopters>a little more</helicopters></likes></dude>" result = ApricotEatsGorilla.hash_to_xml(hash) assert_equal expected, result end end
Version data entries
5 entries across 5 versions & 1 rubygems