Testing & xml

Probably dead obvious, but are there any assertions for easing testing
of xml output, both for builder templates (for RSS feed – something
like a version of assert_tag) and for the new restful stuff.

Couldn’t find anything relevant in the API.

Cheers
Chris

On 8/7/06, Chris T [email protected] wrote:

Probably dead obvious, but are there any assertions for easing testing
of xml output, both for builder templates (for RSS feed – something
like a version of assert_tag) and for the new restful stuff.

Couldn’t find anything relevant in the API.

I just did this at the end of test/test_helper.rb:

Add more helper methods to be used by all tests here…

def assert_xml_tag(xml, conditions)
doc = HTML::Document.new(xml)
assert doc.find(conditions), “expected tag, but no tag found
matching #{conditions.inspect} in:\n#{xml.inspect}”
end

def assert_no_xml_tag(xml, conditions)
doc = HTML::Document.new(xml)
assert !doc.find(conditions), “expected no tag, but found tag
matching #{conditions.inspect} in:\n#{xml.inspect}”
end

Cheers
Chris

Probably could make this a plugin or gem or something.

HTH,
Ed

Ed Howland
http://greenprogrammer.blogspot.com