title: Ignoring attempts to close x with y
body: <p>Ruby on Rails sometimes gives you annoying "Ignoring attempts to close x with y" <a href="https://stackoverflow.com/questions/1671221/rails-assert-selects-annoying-warnings">warnings arising from assert_select</a>. Often these warnings are the result of invalid HTML, but sometimes they appear even if the HTML is valid. The error in my case looks like this while running <code>ruby test/functional/my_controller_test.rb</code> :</p>
  
  <pre><code>..ignoring attempt to close div with h2
    opened at byte 8551, line 207
    closed at byte 9554, line 243
    attributes at open: {"class"=&gt;"my_css_class", "id"=&gt;"object_1"}
    text around open: "  \r\n  \r\n  \r\n  \r\n\r\n  &lt;div class=\"my_css_class"
    text around close: "&lt;/a&gt;\r\n      &lt;/h2&gt;\r\n\r\n      &lt;span"
  </code></pre>
  
  <p>But there is no attempt to close a div with a h2 tag. I tried a HTML validator, but without success. <a href="http://gilesbowkett.blogspot.de/2009/10/ignoring-attempt-to-close-foo-with-bar.html" rel="nofollow noreferrer">The -W0 parameter mentioned by Giles seems to help</a> - <code>ruby -W0 test/functional/my_controller_test.rb</code> gives no longer a warning, but this does not work for <code>rake test:whatever</code>. What does -W0 do, and how can you avoid using it?</p>