require File.join(File.dirname(__FILE__), "..", "helper") class TestShortcutMethod < Test::Unit::TestCase context "Calling []" do setup do ApricotEatsGorilla.setup do |s| s.sort_keys = true s.disable_tag_names_to_lower_camel_case = false s.disable_hash_keys_to_snake_case = false s.disable_hash_keys_to_symbols = false s.nodes_to_namespace = nil end end context "with an XML String" do should "return a Hash containing the XML content" do xml = "Jungle Julia" expected = { :name => "Jungle Julia" } result = ApricotEatsGorilla[xml] assert_equal expected, result end end context "with an XML String and a custom root node" do should "return a Hash containing the XML content starting at custom root" do xml = "Jungle Julia" expected = { :name => "Jungle Julia" } result = ApricotEatsGorilla[xml, "//something"] assert_equal expected, result end end context "with a Hash" do should "return an XML String containing the XML content" do hash = { "apricot" => "eats gorilla" } expected = "eats gorilla" result = ApricotEatsGorilla[hash] assert_equal expected, result end end end end