2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:51:43 -04:00
|
|
|
require "rails-dom-testing"
|
2013-10-12 16:58:51 -04:00
|
|
|
|
2009-04-30 12:55:53 -04:00
|
|
|
module ActionDispatch
|
|
|
|
module Assertions
|
2016-08-06 12:51:43 -04:00
|
|
|
autoload :ResponseAssertions, "action_dispatch/testing/assertions/response"
|
|
|
|
autoload :RoutingAssertions, "action_dispatch/testing/assertions/routing"
|
2009-11-09 22:37:37 -05:00
|
|
|
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2011-05-23 02:13:44 -04:00
|
|
|
include ResponseAssertions
|
|
|
|
include RoutingAssertions
|
2013-10-12 16:58:51 -04:00
|
|
|
include Rails::Dom::Testing::Assertions
|
|
|
|
|
|
|
|
def html_document
|
2020-05-06 00:43:17 -04:00
|
|
|
@html_document ||= if @response.media_type&.end_with?("xml")
|
2014-07-15 12:30:28 -04:00
|
|
|
Nokogiri::XML::Document.parse(@response.body)
|
2013-10-12 16:58:51 -04:00
|
|
|
else
|
2014-11-18 15:47:22 -05:00
|
|
|
Nokogiri::HTML::Document.parse(@response.body)
|
2013-10-12 16:58:51 -04:00
|
|
|
end
|
|
|
|
end
|
2009-04-30 12:55:53 -04:00
|
|
|
end
|
|
|
|
end
|