Forum: Ruby on Rails assert_tag errors (probably only XML-related)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
mailinglists (Guest)
on 2005-12-01 03:50
(Received via mailing list)
Hi,

I'm having problems using assert_tag to test XML output.

I have the following functional test for RSS feeds using assert_tag:
     assert_tag :tag => "rss", :child => { :tag => "channel",
       :child => { :tag => "item",
         :child => { :tag => "enclosure",
           :attributes => {:url => 'http://images-eu.amazon.com/
images/P/3608952128.03.MZZZZZZZ.jpg' }}}}

With RSS this function has two problems. First it treats some tags
special resulting in errors like

ignoring attempt to close item with link
   opened at byte 1635, line 40
   closed at byte 1683, line 41
   attributes at open: {}
   text around open: "\"/>\n    </item>\n    <item>\n      <link>h"
   text around close: "st.host/media/show/1</link>\n      <title"

I could solve that by overwriting HTML::Tag::childless? for XML tests.

Now there is a different mistake:

ignoring attempt to close enclosure with item
   opened at byte 578, line 14
   closed at byte 665, line 15
   attributes at open: {"url"=>"http://images-eu.amazon.com/images/P/
3258058032.03.MZZZZZZZ.jpg"}
   text around open: "00Z</dc:date>\n      <enclosure url=\"http"
   text around close: "MZZZZZZZ.jpg\"/>\n    </item>\n    <item>\n "

The offending code looks like this:
<link>http://test.host/media/show/10</link>
   <title>Wolf Linder: Schweizerische Demokratie - Institutionen,
Prozesse, Perspektiven</title>
   <dc:creator>pneff</dc:creator>
   <dc:subject>Switzerland Politics</dc:subject>
   <dc:date>2005-05-09T02:00Z</dc:date>
   <enclosure url=\"http://images-eu.amazon.com/images/P/
3258058032.03.MZZZZZZZ.jpg\"/>
</item>

It seems as if assert_tag is not able to handle empty elements
(<enclosure ... /> here).

I also run into bugs when I run the functional tests of typo.

Has anyone else experienced this behaviour? Am I doing something
wrong,  is this a problem with my system configuration (OS X, pre-
installed ruby), is it a known bug or should I commit a new bug for it.

I also tested against trunk in subversion with the same results.

Thank you,
Patrice Neff
This topic is locked and can not be replied to.