(Rails)Assert_Select的恼人警告

Cal*_*bHC 16 ruby-on-rails functional-testing

有没有人知道如何让一个rake测试期间assert_select不输出所有那些讨厌的html警告?你知道,像这样的东西:

.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"
Run Code Online (Sandbox Code Playgroud)

谢谢

Rya*_*igg 13

而是您的代码生成无效的HTML.我建议通过验证器运行它并修复所有验证错误.


Syt*_*dij 10

你可以通过使用TESTOPTS v标志找出遇到问题的测试:( bundle exec)rake test TESTOPTS =" - v"

这将给出:

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): .
Run Code Online (Sandbox Code Playgroud)