Sha256: 7f2f30e9a11cd2c8bd6becd9f294b48970a57f772f38a2afb85ac4ec1b641263

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

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_symbol = false
      end
    end

    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.4.4 test/apricoteatsgorilla/test_shortcut_method.rb
smacks-apricoteatsgorilla-0.4.5 test/apricoteatsgorilla/test_shortcut_method.rb