Sha256: b976f332e40d694c1f8317ba55bc0ae3bd5a51b72c1e82c400786303ee03c366
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'test/unit' require 'webget_ramp' class XMLTest < Test::Unit::TestCase MYDIR=File.join('test','webget_ramp') @@formatter=REXML::Formatters::Default.new def test_load_dir_files dirpath=File.join(MYDIR,'xml_test_*.xml') expect=[File.join(MYDIR,'xml_test_1.xml'),File.join(MYDIR,'xml_test_2.xml')] actual=Dir[dirpath].sort assert_equal(expect,actual,"Dir[#{dirpath}] expects test data files") end def test_load_dir dirpath=File.join(MYDIR,'xml_test_*.xml') expect="abcdef" actual='' XML.load_dir(dirpath){|doc| doc.elements.each('foo/bar'){|e| actual+=e.attributes['x']}} assert_equal(expect,actual,'XML.load_dir') end def test_attributes_to_hash doc=REXML::Document.new('<foo a="b" c="d" e="f"/>') expect={"a"=>"b","c"=>"d","e"=>"f"} actual=doc.elements['foo'].attributes.to_hash assert_equal(expect,actual,'XML attributes hash') end def test_element_remove_attributes xml="<foo a='b' c='d'><bar e='f' g='h'>text</bar></foo>" expect="<foo><bar e='f' g='h'>text</bar></foo>" doc=REXML::Document.new(xml) doc.elements[1].remove_attributes actual=doc.to_s assert_equal(expect,actual) end def test_document_remove_attributes xml="<foo a='b' c='d'><bar e='f' g='h'>text</bar></foo>" expect="<foo><bar>text</bar></foo>" doc=REXML::Document.new(xml) doc.remove_attributes actual=doc.to_s assert_equal(expect,actual) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webget_ramp-1.7.1.2 | test/webget_ramp/xml_test.rb |
webget_ramp-1.7.1.1 | test/webget_ramp/xml_test.rb |