aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions.rb
blob: 08c2969685f48c6c5081a9881e134e23ee73bc1c (plain) (tree)
1
2
3
4
5
6
7
8

                             
                           
 

                     

                                                                               


                                 

                              


                                           
                                                                        
                                                     
          
                                                      

         

     
# frozen_string_literal: true

require "rails-dom-testing"

module ActionDispatch
  module Assertions
    autoload :ResponseAssertions, "action_dispatch/testing/assertions/response"
    autoload :RoutingAssertions, "action_dispatch/testing/assertions/routing"

    extend ActiveSupport::Concern

    include ResponseAssertions
    include RoutingAssertions
    include Rails::Dom::Testing::Assertions

    def html_document
      @html_document ||= if @response.content_type.to_s.end_with?("xml")
        Nokogiri::XML::Document.parse(@response.body)
      else
        Nokogiri::HTML::Document.parse(@response.body)
      end
    end
  end
end