module XMLMiniEngineTest::EngineTests
Public Instance Methods
test_array_type_makes_an_array()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 85 def test_array_type_makes_an_array assert_equal_rexml(<<-eoxml) <blog> <posts type="array"> <post>a post</post> <post>another post</post> </posts> </blog> eoxml end
test_blank_returns_empty_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 75 def test_blank_returns_empty_hash assert_equal({}, ActiveSupport::XmlMini.parse(nil)) assert_equal({}, ActiveSupport::XmlMini.parse("")) end
test_children_with_blank_text()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 216 def test_children_with_blank_text skip_unless_extended_engine assert_equal_rexml(<<-eoxml) <root> <products> </products> </root> eoxml end
test_children_with_blank_text_and_attribute()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 226 def test_children_with_blank_text_and_attribute skip_unless_extended_engine assert_equal_rexml(<<-eoxml) <root> <products type="file"> </products> </root> eoxml end
test_children_with_children()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 133 def test_children_with_children assert_equal_rexml(<<-eoxml) <root> <products> <book name="america" id="67890" /> </products> </root> eoxml end
test_children_with_multiple_cdata()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 191 def test_children_with_multiple_cdata skip_unless_extended_engine assert_equal_rexml(<<-eoxml) <root> <products> <![CDATA[cdatablock1]]><![CDATA[cdatablock2]]> </products> </root> eoxml end
test_children_with_non_adjacent_text()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 153 def test_children_with_non_adjacent_text assert_equal_rexml(<<-eoxml) <root> good <products> hello everyone </products> morning </root> eoxml end
test_children_with_simple_cdata()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 179 def test_children_with_simple_cdata skip_unless_extended_engine assert_equal_rexml(<<-eoxml) <root> <products> <![CDATA[cdatablock]]> </products> </root> eoxml end
test_children_with_text()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 143 def test_children_with_text assert_equal_rexml(<<-eoxml) <root> <products> hello everyone </products> </root> eoxml end
test_children_with_text_and_cdata()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 203 def test_children_with_text_and_cdata skip_unless_extended_engine assert_equal_rexml(<<-eoxml) <root> <products> hello <![CDATA[cdatablock]]> morning </products> </root> eoxml end
test_exception_thrown_on_expansion_attack()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 51 def test_exception_thrown_on_expansion_attack assert_raise expansion_attack_error do Hash.from_xml(<<-eoxml) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE member [ <!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;"> <!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;"> <!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;"> <!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;"> <!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;"> <!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;"> <!ENTITY g "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> ]> <member> &a; </member> eoxml end end
test_file_from_xml()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 36 def test_file_from_xml hash = Hash.from_xml(<<-eoxml) <blog> <logo type="file" name="logo.png" content_type="image/png"> </logo> </blog> eoxml assert hash.key?("blog") assert hash["blog"].key?("logo") file = hash["blog"]["logo"] assert_equal "logo.png", file.original_filename assert_equal "image/png", file.content_type end
test_one_node_document_as_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 96 def test_one_node_document_as_hash assert_equal_rexml(<<-eoxml) <products/> eoxml end
test_one_node_with_attributes_document_as_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 102 def test_one_node_with_attributes_document_as_hash assert_equal_rexml(<<-eoxml) <products foo="bar"/> eoxml end
test_parse_from_frozen_string()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 80 def test_parse_from_frozen_string xml_string = "<root/>".freeze assert_equal({ "root" => {} }, ActiveSupport::XmlMini.parse(xml_string)) end
test_parse_from_io()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 165 def test_parse_from_io skip_unless_extended_engine assert_equal_rexml(StringIO.new(<<-eoxml)) <root> good <products> hello everyone </products> morning </root> eoxml end
test_products_node_with_book_node_as_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 108 def test_products_node_with_book_node_as_hash assert_equal_rexml(<<-eoxml) <products> <book name="awesome" id="12345" /> </products> eoxml end
test_products_node_with_two_book_nodes_as_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 116 def test_products_node_with_two_book_nodes_as_hash assert_equal_rexml(<<-eoxml) <products> <book name="awesome" id="12345" /> <book name="america" id="67890" /> </products> eoxml end
test_setting_backend()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 71 def test_setting_backend assert_engine_class ActiveSupport::XmlMini.backend end
test_single_node_with_content_as_hash()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 125 def test_single_node_with_content_as_hash assert_equal_rexml(<<-eoxml) <products> hello world </products> eoxml end
Private Instance Methods
assert_engine_class(actual)
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 241 def assert_engine_class(actual) assert_equal ActiveSupport.const_get("XmlMini_#{engine}"), actual end
assert_equal_rexml(xml)
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 245 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
engine()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 237 def engine raise NotImplementedError end
expansion_attack_error()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 252 def expansion_attack_error raise NotImplementedError end
extended_engine?()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 256 def extended_engine? true end
skip_unless_extended_engine()
click to toggle source
# File activesupport/test/xml_mini/xml_mini_engine_test.rb, line 260 def skip_unless_extended_engine skip "#{engine} is not an extended engine" unless extended_engine? end