Ruby on Rails有時會給您帶來惱人的「忽略嘗試用y關閉x」warnings arising from assert_select。這些警告通常是HTML無效的結果,但即使HTML有效,它們有時也會出現。在我的情況的錯誤看起來像運行ruby test/functional/my_controller_test.rb
這個while:忽略嘗試使用y關閉x
..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"
但沒有試圖關閉一個div用H2標籤。我嘗試了一個HTML驗證器,但沒有成功。 The -W0 parameter mentioned by Giles seems to help - ruby -W0 test/functional/my_controller_test.rb
不再給出警告,但這對rake test:whatever
不起作用。 -W0做什麼,以及如何避免使用它?