1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test/xml_mini/rexml_engine_test.rb

38 lines
809 B
Ruby
Raw Normal View History

require 'abstract_unit'
require 'active_support/xml_mini'
2012-01-05 20:12:46 -05:00
class REXMLEngineTest < ActiveSupport::TestCase
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
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)
end
2013-04-02 02:20:25 -04:00
private
def assert_equal_rexml(xml)
parsed_xml = XmlMini.parse(xml)
xml.rewind if xml.respond_to?(:rewind)
hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
2013-04-02 02:20:25 -04:00
assert_equal(hash, parsed_xml)
end
end