Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Rails) Assert_Select's Annoying Warnings

Does anyone know how to make assert_select not output all those nasty html warnings during a rake test? You know, like this stuff:

.ignoring attempt to close body with div
opened at byte 1036, line 5
closed at byte 5342, line 42
attributes at open: {"class"=>"inner02"}
text around open: "</script>\r\t</head>\r\t<body class=\"inner02"
text around close: "\t</div>\r\t\t\t</div>\r\t\t</div>\r\t</body>\r</ht"

Thanks

like image 417
CalebHC Avatar asked Nov 04 '09 01:11

CalebHC


3 Answers

It's rather that your code is generating invalid HTML. I suggest running it through a validator and fixing all the validation errors.

like image 55
Ryan Bigg Avatar answered Sep 19 '22 11:09

Ryan Bigg


You can find out which test ran into the problem by using the TESTOPTS v flag: (bundle exec) rake test TESTOPTS="-v"

This will give:

test: Request the homepage should have a node list. (PresentControllerTest): .
test: Request the homepage should have the correct title. (PresentControllerTest): ignoring attempt to close div with body
  opened at byte 4378, line 89
  closed at byte 17745, line 393
  attributes at open: {"class"=>"colleft"}
  text around open: "class=\"colmid\"> \n\t\t\t<div class=\"colleft\""
  text around close: "x2.js\" ></script>\n  </body>\n</html>\n\n"
ignoring attempt to close div with html
  opened at byte 4378, line 89
  closed at byte 17753, line 394
  attributes at open: {"class"=>"colleft"}
  text around open: "class=\"colmid\"> \n\t\t\t<div class=\"colleft\""
  text around close: "</script>\n  </body>\n</html>\n\n"
.
test: Request the homepage should not set the flash. (PresentControllerTest): .
test: Request the homepage should respond with 200. (PresentControllerTest): .
like image 25
Sytse Sijbrandij Avatar answered Sep 22 '22 11:09

Sytse Sijbrandij


Rails's HTML scanner expects XHTML, if you're using HTML4 where tags don't have explicit closing tags, you may get this warning... doesn't look like solved issue

  • http://dev.rubyonrails.org/ticket/1937
  • http://gilesbowkett.blogspot.com/2009/10/ignoring-attempt-to-close-foo-with-bar.html
like image 42
ryw Avatar answered Sep 22 '22 11:09

ryw