From c4fb89b2044393df1583f4827c8b811e852b9f6d Mon Sep 17 00:00:00 2001 From: NAITOH Jun Date: Thu, 4 Jul 2024 07:09:42 +0900 Subject: [PATCH] fix multiple root elements ## Why? XML with multiple root elements is invalid. See: https://github.com/ruby/rexml/pull/160#discussion_r1653778277 --- test/test_pullparser.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test_pullparser.rb b/test/test_pullparser.rb index 073d896d..0aca46be 100644 --- a/test/test_pullparser.rb +++ b/test/test_pullparser.rb @@ -63,8 +63,10 @@ def test_entity_replacement end def test_character_references - source = 'AB' + source = 'AB' parser = REXML::Parsers::PullParser.new( source ) + + events = {} element_name = '' while parser.has_next? event = parser.pull @@ -72,14 +74,12 @@ def test_character_references when :start_element element_name = event[0] when :text - case element_name - when 'a' - assert_equal('A', event[1]) - when 'b' - assert_equal('B', event[1]) - end + events[element_name] = event[1] end end + + assert_equal('A', events['a']) + assert_equal("B", events['b']) end def test_text_content_with_line_breaks