Sha256: 476e86e8a118aaec0e549247cb268139c830ff6978004995117991a6c94cf2a3

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require File.join(File.dirname(__FILE__), "..", "helper")

class ShortcutMethodTest < Test::Unit::TestCase

  context "Calling []" do
    setup { ApricotEatsGorilla.sort_keys = true }

    context "with an XML String" do
      should "return a Hash containing the XML content" do
        xml = "<root><name>Jungle Julia</name></root>"
        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 = "<root><something><name>Jungle Julia</name></something></root>"
        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 = "<apricot>eats gorilla</apricot>"

        result = ApricotEatsGorilla[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/shortcut_method_test.rb
smacks-apricoteatsgorilla-0.3.61 test/apricoteatsgorilla/shortcut_method_test.rb