2009-03-09 20:27:39 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
require 'active_support/xml_mini'
|
|
|
|
|
2012-01-05 20:12:46 -05:00
|
|
|
class REXMLEngineTest < ActiveSupport::TestCase
|
2009-03-09 20:27:39 -04:00
|
|
|
include ActiveSupport
|
|
|
|
|
|
|
|
def test_default_is_rexml
|
|
|
|
assert_equal XmlMini_REXML, XmlMini.backend
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_set_rexml_as_backend
|
|
|
|
XmlMini.backend = 'REXML'
|
|
|
|
assert_equal XmlMini_REXML, XmlMini.backend
|
|
|
|
end
|
2009-05-17 11:37:30 -04:00
|
|
|
|
|
|
|
def test_parse_from_io
|
|
|
|
XmlMini.backend = 'REXML'
|
|
|
|
io = StringIO.new(<<-eoxml)
|
|
|
|
<root>
|
|
|
|
good
|
|
|
|
<products>
|
|
|
|
hello everyone
|
|
|
|
</products>
|
|
|
|
morning
|
|
|
|
</root>
|
|
|
|
eoxml
|
2013-04-02 02:20:25 -04:00
|
|
|
assert_equal_rexml(io)
|
2009-05-17 11:37:30 -04:00
|
|
|
end
|
2013-04-02 02:20:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def assert_equal_rexml(xml)
|
|
|
|
parsed_xml = XmlMini.parse(xml)
|
2013-06-15 18:32:33 -04:00
|
|
|
xml.rewind if xml.respond_to?(:rewind)
|
2013-05-22 09:35:47 -04:00
|
|
|
hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
|
2013-04-02 02:20:25 -04:00
|
|
|
assert_equal(hash, parsed_xml)
|
|
|
|
end
|
2009-03-09 20:27:39 -04:00
|
|
|
end
|