【发布时间】:2012-07-06 16:55:37
【问题描述】:
Ruby on Rails 有时会给您带来烦人的“忽略用 y 关闭 x 的尝试”warnings arising from assert_select。这些警告通常是无效 HTML 的结果,但有时即使 HTML 有效,它们也会出现。我的错误在运行ruby test/functional/my_controller_test.rb 时看起来像这样:
..ignoring attempt to close div with h2
opened at byte 8551, line 207
closed at byte 9554, line 243
attributes at open: {"class"=>"my_css_class", "id"=>"object_1"}
text around open: " \r\n \r\n \r\n \r\n\r\n <div class=\"my_css_class"
text around close: "</a>\r\n </h2>\r\n\r\n <span"
但没有尝试关闭带有 h2 标签的 div。我尝试了一个 HTML 验证器,但没有成功。 The -W0 parameter mentioned by Giles seems to help - ruby -W0 test/functional/my_controller_test.rb 不再给出警告,但这不适用于 rake test:whatever。 -W0 有什么作用,如何避免使用它?
【问题讨论】:
标签: html ruby-on-rails ruby testing