aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions.rb
blob: 41d00b5e2b4cfef4e2882a94f2c9853d67bc37e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 =~ /xml$/
        Nokogiri::XML::Document.parse(@response.body)
      else
        Nokogiri::HTML::DocumentFragment.parse(@response.body)
      end
    end
  end
end