As you may be aware, assert_select spits out annoying warnings when testing XML output that contains auto-closing HTML tags. I submitted a patch fix the issue a few weeks ago.
If you need this fix and don’t want to patch Rails directly, you can monkey patch Rails. But it’s a little tricky because the module is re-loaded during testing after environment.rb is executed. Therefore, the usual method of putting a patch in lib/ and requiring it from environment.rb doesn’t work.
The patch is simply:
module ActionController::TestProcess
def html_document
xml =@response.content_type =~/xml$/@html_document||=HTML::Document.new(@response.body, false, xml)
endend
However it needs to be placed after the require 'test_help' statement in test/test_helper.rb or it will be overwritten.
Quick fix assert_select for XML testing
As you may be aware,
assert_select
spits out annoying warnings when testing XML output that contains auto-closing HTML tags. I submitted a patch fix the issue a few weeks ago.If you need this fix and don’t want to patch Rails directly, you can monkey patch Rails. But it’s a little tricky because the module is re-loaded during testing after
environment.rb
is executed. Therefore, the usual method of putting a patch inlib/
and requiring it fromenvironment.rb
doesn’t work.The patch is simply:
However it needs to be placed after the
require 'test_help'
statement intest/test_helper.rb
or it will be overwritten.