When run against an action that generates the attached HTML, the following assert_tag gives erroneous warnings:
def test_index
get :index
assert_response :success
assert_tag(:tag => 'a', :child => 'fade', :attributes => {
:href => "/hosts/show/1"
})
end
Warnings:
ignoring attempt to close li with ul
opened at byte 328, line 14
closed at byte 365, line 15
attributes at open: {}
text around open: "ts/show/1\">fade</a>\n<li><a href=\"/hosts/"
text around close: "ts/show/2\">fade</a>\n</ul>\n\n<p><a href=\"/"
ignoring attempt to close td with table
opened at byte 504, line 23
closed at byte 546, line 24
attributes at open: {}
text around open: "d>Fade<td>60 seconds<td><a href=\"/test_t"
text around close: "es/edit/1\">Edit</a>\n</table>\n\n<p><a href"
ignoring attempt to close p with div
opened at byte 556, line 26
closed at byte 598, line 28
attributes at open: {}
text around open: ">Edit</a>\n</table>\n\n<p><a href=\"/home/ne"
text around close: ">New Test Type</a>\n\n</div>\n</body>\n</htm"
ignoring attempt to close p with body
opened at byte 556, line 26
closed at byte 605, line 29
attributes at open: {}
text around open: ">Edit</a>\n</table>\n\n<p><a href=\"/home/ne"
text around close: "st Type</a>\n\n</div>\n</body>\n</html>\n\n"
ignoring attempt to close p with html
opened at byte 556, line 26
closed at byte 613, line 30
attributes at open: {}
text around open: ">Edit</a>\n</table>\n\n<p><a href=\"/home/ne"
text around close: "/a>\n\n</div>\n</body>\n</html>\n\n"
As you can see from the HTML 4 Element Index at http://www.w3.org/TR/REC-html40/index/elements.html, the end-tag is optional for all the cases it is warning about.