I am creating an XML document: I want to unit test at least to make sure it is well formed. So far, I could only approximate this using the "hasElements" in the REXML library.
Is there a better way? It is preferable to use the built-in libraries (I mean the libraries that come with the standard Ruby 1.8.x distribution).
require "test/unit"
require 'rexml/document'
require 'test/unit/ui/console/testrunner'
include REXML
class TestBasic < Test::Unit::TestCase
def test_createXML
my_xml=...create doc here...
doc = Document.new(my_xml);
assert(doc.has_elements?);
end
end
Test::Unit::UI::Console::TestRunner.run(TestBasic);
source
share