module ActionDispatch::Assertions

def html_document

def html_document
  @html_document ||= if @response.media_type&.end_with?("xml")
    Nokogiri::XML::Document.parse(@response.body)
  else
    Rails::Dom::Testing.html_document.parse(@response.body)
  end
end