From 305e2922a4b358f0ae5630672b6144d3013b603d Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 19 Nov 2016 10:59:24 -0500 Subject: Create `CommonXMLMiniAdapterTest`; common tests module Created a new module (a la Action Cable subscription adapter's test suite) to be included in all sub class test to ensure compatability and reduce duplicated code. --- activesupport/test/xml_mini/common.rb | 229 +++++++++++++++++++++ activesupport/test/xml_mini/jdom_engine_test.rb | 142 +------------ activesupport/test/xml_mini/libxml_engine_test.rb | 190 +---------------- .../test/xml_mini/libxmlsax_engine_test.rb | 183 +--------------- .../test/xml_mini/nokogiri_engine_test.rb | 205 +----------------- .../test/xml_mini/nokogirisax_engine_test.rb | 206 +----------------- activesupport/test/xml_mini/rexml_engine_test.rb | 40 ++-- 7 files changed, 279 insertions(+), 916 deletions(-) create mode 100644 activesupport/test/xml_mini/common.rb (limited to 'activesupport/test') diff --git a/activesupport/test/xml_mini/common.rb b/activesupport/test/xml_mini/common.rb new file mode 100644 index 0000000000..900fb31ba3 --- /dev/null +++ b/activesupport/test/xml_mini/common.rb @@ -0,0 +1,229 @@ +module CommonXMLMiniAdapterTest + def setup + @default_backend = ActiveSupport::XmlMini.backend + ActiveSupport::XmlMini.backend = adapter_name + end + + def teardown + ActiveSupport::XmlMini.backend = @default_backend + end + + def test_file_from_xml + hash = Hash.from_xml(<<-eoxml) + + + + + eoxml + assert hash.has_key?("blog") + assert hash["blog"].has_key?("logo") + + file = hash["blog"]["logo"] + assert_equal "logo.png", file.original_filename + assert_equal "image/png", file.content_type + end + + def test_exception_thrown_on_expansion_attack + assert_raise expansion_attack_error do + attack_xml = <<-EOT + + + + + + + + + ]> + + &a; + + EOT + Hash.from_xml(attack_xml) + end + end + + def test_setting_backend + ActiveSupport::XmlMini.backend = adapter_name + assert_equal ActiveSupport.const_get("XmlMini_#{adapter_name}"), ActiveSupport::XmlMini.backend + #assert_equal ActiveSupport::XmlMini_Nokogiri + end + + def test_blank_returns_empty_hash + assert_equal({}, ActiveSupport::XmlMini.parse(nil)) + assert_equal({}, ActiveSupport::XmlMini.parse("")) + end + + def test_array_type_makes_an_array + assert_equal_rexml(<<-eoxml) + + + a post + another post + + + eoxml + end + + def test_one_node_document_as_hash + assert_equal_rexml(<<-eoxml) + + eoxml + end + + def test_one_node_with_attributes_document_as_hash + assert_equal_rexml(<<-eoxml) + + eoxml + end + + def test_products_node_with_book_node_as_hash + assert_equal_rexml(<<-eoxml) + + + + eoxml + end + + def test_products_node_with_two_book_nodes_as_hash + assert_equal_rexml(<<-eoxml) + + + + + eoxml + end + + def test_single_node_with_content_as_hash + assert_equal_rexml(<<-eoxml) + + hello world + + eoxml + end + + def test_children_with_children + assert_equal_rexml(<<-eoxml) + + + + + + eoxml + end + + def test_children_with_text + assert_equal_rexml(<<-eoxml) + + + hello everyone + + + eoxml + end + + def test_children_with_non_adjacent_text + assert_equal_rexml(<<-eoxml) + + good + + hello everyone + + morning + + eoxml + end + + def test_parse_from_io + jdom_skip + + io = StringIO.new(<<-eoxml) + + good + + hello everyone + + morning + + eoxml + assert_equal_rexml(io) + end + + def test_children_with_simple_cdata + jdom_skip + + assert_equal_rexml(<<-eoxml) + + + + + + eoxml + end + + def test_children_with_multiple_cdata + jdom_skip + + assert_equal_rexml(<<-eoxml) + + + + + + eoxml + end + + def test_children_with_text_and_cdata + jdom_skip + + assert_equal_rexml(<<-eoxml) + + + hello + morning + + + eoxml + end + + def test_children_with_blank_text + jdom_skip + + assert_equal_rexml(<<-eoxml) + + + + eoxml + end + + def test_children_with_blank_text_and_attribute + jdom_skip + + assert_equal_rexml(<<-eoxml) + + + + eoxml + end + + private + def adapter_name + raise NotImplementedError + end + + def assert_equal_rexml(xml) + parsed_xml = ActiveSupport::XmlMini.parse(xml) + xml.rewind if xml.respond_to?(:rewind) + hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } + assert_equal(hash, parsed_xml) + end + + def expansion_attack_error + raise NotImplementedError + end + + def jdom_skip + skip "JDOM does not support this test" if adapter_name == "JDOM" + end +end diff --git a/activesupport/test/xml_mini/jdom_engine_test.rb b/activesupport/test/xml_mini/jdom_engine_test.rb index 66b15aed4a..f42fc195cc 100644 --- a/activesupport/test/xml_mini/jdom_engine_test.rb +++ b/activesupport/test/xml_mini/jdom_engine_test.rb @@ -2,33 +2,12 @@ if RUBY_PLATFORM.include?("java") require "abstract_unit" require "active_support/xml_mini" require "active_support/core_ext/hash/conversions" + require_relative "./common" class JDOMEngineTest < ActiveSupport::TestCase FILES_DIR = File.dirname(__FILE__) + "/../fixtures/xml" - def setup - @default_backend = ActiveSupport::XmlMini.backend - ActiveSupport::XmlMini.backend = "JDOM" - end - - def teardown - ActiveSupport::XmlMini.backend = @default_backend - end - - def test_file_from_xml - hash = Hash.from_xml(<<-eoxml) - - - - - eoxml - assert hash.has_key?("blog") - assert hash["blog"].has_key?("logo") - - file = hash["blog"]["logo"] - assert_equal "logo.png", file.original_filename - assert_equal "image/png", file.content_type - end + include CommonXMLMiniAdapterTest def test_not_allowed_to_expand_entities_to_files attack_xml = <<-EOT @@ -61,121 +40,14 @@ if RUBY_PLATFORM.include?("java") assert_equal "x", Hash.from_xml(attack_xml)["member"] end - def test_exception_thrown_on_expansion_attack - assert_raise Java::OrgXmlSax::SAXParseException do - attack_xml = <<-EOT - - - - - - - - ]> - - &a; - - EOT - Hash.from_xml(attack_xml) - end - end - - def test_setting_JDOM_as_backend - ActiveSupport::XmlMini.backend = "JDOM" - assert_equal ActiveSupport::XmlMini_JDOM, ActiveSupport::XmlMini.backend - end - - def test_blank_returns_empty_hash - assert_equal({}, ActiveSupport::XmlMini.parse(nil)) - assert_equal({}, ActiveSupport::XmlMini.parse("")) - end - - def test_array_type_makes_an_array - assert_equal_rexml(<<-eoxml) - - - a post - another post - - - eoxml - end - - def test_one_node_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_one_node_with_attributes_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_products_node_with_book_node_as_hash - assert_equal_rexml(<<-eoxml) - - - - eoxml - end - - def test_products_node_with_two_book_nodes_as_hash - assert_equal_rexml(<<-eoxml) - - - - - eoxml - end - - def test_single_node_with_content_as_hash - assert_equal_rexml(<<-eoxml) - - hello world - - eoxml - end - - def test_children_with_children - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end + private - def test_children_with_text - assert_equal_rexml(<<-eoxml) - - - hello everyone - - - eoxml + def adapter_name + "JDOM" end - def test_children_with_non_adjacent_text - assert_equal_rexml(<<-eoxml) - - good - - hello everyone - - morning - - eoxml + def expansion_attack_error + Java::OrgXmlSax::SAXParseException end - - private - def assert_equal_rexml(xml) - parsed_xml = ActiveSupport::XmlMini.parse(xml) - hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } - assert_equal(hash, parsed_xml) - end end end diff --git a/activesupport/test/xml_mini/libxml_engine_test.rb b/activesupport/test/xml_mini/libxml_engine_test.rb index ae3a5562e0..ff4759b082 100644 --- a/activesupport/test/xml_mini/libxml_engine_test.rb +++ b/activesupport/test/xml_mini/libxml_engine_test.rb @@ -6,196 +6,24 @@ else require "abstract_unit" require "active_support/xml_mini" require "active_support/core_ext/hash/conversions" + require_relative "./common" class LibxmlEngineTest < ActiveSupport::TestCase - def setup - @default_backend = ActiveSupport::XmlMini.backend - ActiveSupport::XmlMini.backend = "LibXML" + include CommonXMLMiniAdapterTest + def setup + super LibXML::XML::Error.set_handler(&lambda { |error| }) #silence libxml, exceptions will do end - def teardown - ActiveSupport::XmlMini.backend = @default_backend - end - - def test_exception_thrown_on_expansion_attack - assert_raise LibXML::XML::Error do - attack_xml = %{ - - - - - - - - ]> - - &a; - - } - Hash.from_xml(attack_xml) - end - end - - def test_setting_libxml_as_backend - ActiveSupport::XmlMini.backend = "LibXML" - assert_equal ActiveSupport::XmlMini_LibXML, ActiveSupport::XmlMini.backend - end - - def test_blank_returns_empty_hash - assert_equal({}, ActiveSupport::XmlMini.parse(nil)) - assert_equal({}, ActiveSupport::XmlMini.parse("")) - end - - def test_array_type_makes_an_array - assert_equal_rexml(<<-eoxml) - - - a post - another post - - - eoxml - end - - def test_one_node_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_one_node_with_attributes_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_products_node_with_book_node_as_hash - assert_equal_rexml(<<-eoxml) - - - - eoxml - end - - def test_products_node_with_two_book_nodes_as_hash - assert_equal_rexml(<<-eoxml) - - - - - eoxml - end - - def test_single_node_with_content_as_hash - assert_equal_rexml(<<-eoxml) - - hello world - - eoxml - end - - def test_children_with_children - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text - assert_equal_rexml(<<-eoxml) - - - hello everyone - - - eoxml - end - - def test_children_with_non_adjacent_text - assert_equal_rexml(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - end - - def test_parse_from_io - io = StringIO.new(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - assert_equal_rexml(io) - end - - def test_children_with_simple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_multiple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text_and_cdata - assert_equal_rexml(<<-eoxml) - - - hello - morning - - - eoxml - end + private - def test_children_with_blank_text - assert_equal_rexml(<<-eoxml) - - - - eoxml + def adapter_name + "LibXML" end - def test_children_with_blank_text_and_attribute - assert_equal_rexml(<<-eoxml) - - - - eoxml + def expansion_attack_error + LibXML::XML::Error end - - private - def assert_equal_rexml(xml) - parsed_xml = ActiveSupport::XmlMini.parse(xml) - xml.rewind if xml.respond_to?(:rewind) - hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } - assert_equal(hash, parsed_xml) - end end - end diff --git a/activesupport/test/xml_mini/libxmlsax_engine_test.rb b/activesupport/test/xml_mini/libxmlsax_engine_test.rb index f52afd273e..73eff9ac44 100644 --- a/activesupport/test/xml_mini/libxmlsax_engine_test.rb +++ b/activesupport/test/xml_mini/libxmlsax_engine_test.rb @@ -6,188 +6,19 @@ else require "abstract_unit" require "active_support/xml_mini" require "active_support/core_ext/hash/conversions" + require_relative "./common" class LibXMLSAXEngineTest < ActiveSupport::TestCase - def setup - @default_backend = ActiveSupport::XmlMini.backend - ActiveSupport::XmlMini.backend = "LibXMLSAX" - end - - def teardown - ActiveSupport::XmlMini.backend = @default_backend - end - - def test_exception_thrown_on_expansion_attack - assert_raise LibXML::XML::Error do - attack_xml = <<-EOT - - - - - - - - - ]> - - &a; - - EOT - - Hash.from_xml(attack_xml) - end - end - - def test_setting_libxml_as_backend - ActiveSupport::XmlMini.backend = "LibXMLSAX" - assert_equal ActiveSupport::XmlMini_LibXMLSAX, ActiveSupport::XmlMini.backend - end - - def test_blank_returns_empty_hash - assert_equal({}, ActiveSupport::XmlMini.parse(nil)) - assert_equal({}, ActiveSupport::XmlMini.parse("")) - end + include CommonXMLMiniAdapterTest - def test_array_type_makes_an_array - assert_equal_rexml(<<-eoxml) - - - a post - another post - - - eoxml - end - - def test_one_node_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_one_node_with_attributes_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_products_node_with_book_node_as_hash - assert_equal_rexml(<<-eoxml) - - - - eoxml - end - - def test_products_node_with_two_book_nodes_as_hash - assert_equal_rexml(<<-eoxml) - - - - - eoxml - end - - def test_single_node_with_content_as_hash - assert_equal_rexml(<<-eoxml) - - hello world - - eoxml - end - - def test_children_with_children - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text - assert_equal_rexml(<<-eoxml) - - - hello everyone - - - eoxml - end - - def test_children_with_non_adjacent_text - assert_equal_rexml(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - end - - def test_parse_from_io - io = StringIO.new(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - assert_equal_rexml(io) - end - - def test_children_with_simple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_multiple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end + private - def test_children_with_text_and_cdata - assert_equal_rexml(<<-eoxml) - - - hello - morning - - - eoxml + def adapter_name + "LibXMLSAX" end - def test_children_with_blank_text - assert_equal_rexml(<<-eoxml) - - - - eoxml + def expansion_attack_error + LibXML::XML::Error end - - private - def assert_equal_rexml(xml) - parsed_xml = ActiveSupport::XmlMini.parse(xml) - xml.rewind if xml.respond_to?(:rewind) - hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } - assert_equal(hash, parsed_xml) - end end - end diff --git a/activesupport/test/xml_mini/nokogiri_engine_test.rb b/activesupport/test/xml_mini/nokogiri_engine_test.rb index 44b82da4e4..b0c4985a50 100644 --- a/activesupport/test/xml_mini/nokogiri_engine_test.rb +++ b/activesupport/test/xml_mini/nokogiri_engine_test.rb @@ -6,210 +6,19 @@ else require "abstract_unit" require "active_support/xml_mini" require "active_support/core_ext/hash/conversions" + require_relative "./common" class NokogiriEngineTest < ActiveSupport::TestCase - def setup - @default_backend = ActiveSupport::XmlMini.backend - ActiveSupport::XmlMini.backend = "Nokogiri" - end - - def teardown - ActiveSupport::XmlMini.backend = @default_backend - end - - def test_file_from_xml - hash = Hash.from_xml(<<-eoxml) - - - - - eoxml - assert hash.has_key?("blog") - assert hash["blog"].has_key?("logo") - - file = hash["blog"]["logo"] - assert_equal "logo.png", file.original_filename - assert_equal "image/png", file.content_type - end + include CommonXMLMiniAdapterTest - def test_exception_thrown_on_expansion_attack - assert_raise Nokogiri::XML::SyntaxError do - attack_xml = <<-EOT - - - - - - - - - ]> - - &a; - - EOT - Hash.from_xml(attack_xml) - end - end - - def test_setting_nokogiri_as_backend - ActiveSupport::XmlMini.backend = "Nokogiri" - assert_equal ActiveSupport::XmlMini_Nokogiri, ActiveSupport::XmlMini.backend - end - - def test_blank_returns_empty_hash - assert_equal({}, ActiveSupport::XmlMini.parse(nil)) - assert_equal({}, ActiveSupport::XmlMini.parse("")) - end - - def test_array_type_makes_an_array - assert_equal_rexml(<<-eoxml) - - - a post - another post - - - eoxml - end - - def test_one_node_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_one_node_with_attributes_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_products_node_with_book_node_as_hash - assert_equal_rexml(<<-eoxml) - - - - eoxml - end - - def test_products_node_with_two_book_nodes_as_hash - assert_equal_rexml(<<-eoxml) - - - - - eoxml - end - - def test_single_node_with_content_as_hash - assert_equal_rexml(<<-eoxml) - - hello world - - eoxml - end - - def test_children_with_children - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text - assert_equal_rexml(<<-eoxml) - - - hello everyone - - - eoxml - end - - def test_children_with_non_adjacent_text - assert_equal_rexml(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - end - - def test_parse_from_io - io = StringIO.new(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - assert_equal_rexml(io) - end - - def test_children_with_simple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_multiple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text_and_cdata - assert_equal_rexml(<<-eoxml) - - - hello - morning - - - eoxml - end + private - def test_children_with_blank_text - assert_equal_rexml(<<-eoxml) - - - - eoxml + def expansion_attack_error + Nokogiri::XML::SyntaxError end - def test_children_with_blank_text_and_attribute - assert_equal_rexml(<<-eoxml) - - - - eoxml + def adapter_name + "Nokogiri" end - - private - def assert_equal_rexml(xml) - parsed_xml = ActiveSupport::XmlMini.parse(xml) - xml.rewind if xml.respond_to?(:rewind) - hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } - assert_equal(hash, parsed_xml) - end end - end diff --git a/activesupport/test/xml_mini/nokogirisax_engine_test.rb b/activesupport/test/xml_mini/nokogirisax_engine_test.rb index 24b35cadf6..5be339b826 100644 --- a/activesupport/test/xml_mini/nokogirisax_engine_test.rb +++ b/activesupport/test/xml_mini/nokogirisax_engine_test.rb @@ -6,211 +6,19 @@ else require "abstract_unit" require "active_support/xml_mini" require "active_support/core_ext/hash/conversions" + require_relative "./common" class NokogiriSAXEngineTest < ActiveSupport::TestCase - def setup - @default_backend = ActiveSupport::XmlMini.backend - ActiveSupport::XmlMini.backend = "NokogiriSAX" - end - - def teardown - ActiveSupport::XmlMini.backend = @default_backend - end - - def test_file_from_xml - hash = Hash.from_xml(<<-eoxml) - - - - - eoxml - assert hash.has_key?("blog") - assert hash["blog"].has_key?("logo") - - file = hash["blog"]["logo"] - assert_equal "logo.png", file.original_filename - assert_equal "image/png", file.content_type - end - - def test_exception_thrown_on_expansion_attack - assert_raise RuntimeError do - attack_xml = <<-EOT - - - - - - - - - ]> - - &a; - - EOT - - Hash.from_xml(attack_xml) - end - end - - def test_setting_nokogirisax_as_backend - ActiveSupport::XmlMini.backend = "NokogiriSAX" - assert_equal ActiveSupport::XmlMini_NokogiriSAX, ActiveSupport::XmlMini.backend - end - - def test_blank_returns_empty_hash - assert_equal({}, ActiveSupport::XmlMini.parse(nil)) - assert_equal({}, ActiveSupport::XmlMini.parse("")) - end - - def test_array_type_makes_an_array - assert_equal_rexml(<<-eoxml) - - - a post - another post - - - eoxml - end - - def test_one_node_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_one_node_with_attributes_document_as_hash - assert_equal_rexml(<<-eoxml) - - eoxml - end - - def test_products_node_with_book_node_as_hash - assert_equal_rexml(<<-eoxml) - - - - eoxml - end + include CommonXMLMiniAdapterTest - def test_products_node_with_two_book_nodes_as_hash - assert_equal_rexml(<<-eoxml) - - - - - eoxml - end - - def test_single_node_with_content_as_hash - assert_equal_rexml(<<-eoxml) - - hello world - - eoxml - end - - def test_children_with_children - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text - assert_equal_rexml(<<-eoxml) - - - hello everyone - - - eoxml - end - - def test_children_with_non_adjacent_text - assert_equal_rexml(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - end - - def test_parse_from_io - io = StringIO.new(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - assert_equal_rexml(io) - end - - def test_children_with_simple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_multiple_cdata - assert_equal_rexml(<<-eoxml) - - - - - - eoxml - end - - def test_children_with_text_and_cdata - assert_equal_rexml(<<-eoxml) - - - hello - morning - - - eoxml - end + private - def test_children_with_blank_text - assert_equal_rexml(<<-eoxml) - - - - eoxml + def adapter_name + "NokogiriSAX" end - def test_children_with_blank_text_and_attribute - assert_equal_rexml(<<-eoxml) - - - - eoxml + def expansion_attack_error + RuntimeError end - - private - def assert_equal_rexml(xml) - parsed_xml = ActiveSupport::XmlMini.parse(xml) - xml.rewind if xml.respond_to?(:rewind) - hash = ActiveSupport::XmlMini.with_backend("REXML") { ActiveSupport::XmlMini.parse(xml) } - assert_equal(hash, parsed_xml) - end end - end diff --git a/activesupport/test/xml_mini/rexml_engine_test.rb b/activesupport/test/xml_mini/rexml_engine_test.rb index dc62f3f671..0f4e690746 100644 --- a/activesupport/test/xml_mini/rexml_engine_test.rb +++ b/activesupport/test/xml_mini/rexml_engine_test.rb @@ -1,44 +1,30 @@ require "abstract_unit" require "active_support/xml_mini" +require_relative "./common" class REXMLEngineTest < ActiveSupport::TestCase - def test_default_is_rexml - assert_equal ActiveSupport::XmlMini_REXML, ActiveSupport::XmlMini.backend - end + include CommonXMLMiniAdapterTest - def test_set_rexml_as_backend - ActiveSupport::XmlMini.backend = "REXML" + def test_default_is_rexml assert_equal ActiveSupport::XmlMini_REXML, ActiveSupport::XmlMini.backend end - def test_parse_from_io - ActiveSupport::XmlMini.backend = "REXML" - io = StringIO.new(<<-eoxml) - - good - - hello everyone - - morning - - eoxml - hash = ActiveSupport::XmlMini.parse(io) - assert hash.has_key?("root") - assert hash["root"].has_key?("products") - assert_match "good", hash["root"]["__content__"] - products = hash["root"]["products"] - assert products.has_key?("__content__") - assert_match "hello everyone", products["__content__"] - end - def test_parse_from_empty_string - ActiveSupport::XmlMini.backend = "REXML" assert_equal({}, ActiveSupport::XmlMini.parse("")) end def test_parse_from_frozen_string - ActiveSupport::XmlMini.backend = "REXML" xml_string = "".freeze assert_equal({ "root" => {} }, ActiveSupport::XmlMini.parse(xml_string)) end + + private + + def adapter_name + "REXML" + end + + def expansion_attack_error + RuntimeError + end end -- cgit v1.2.3