From 86f77894803a6b2dc79d611fa9b51ebc67f1263b Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Tue, 20 Dec 2016 19:21:41 +1030 Subject: Revise the "XML is not HTML" test It was depending on a side-effect of the old html-scanner, so was no longer proving what it intended to. Instead, assert more directly about the resulting observable difference. --- actionpack/test/controller/test_case_test.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'actionpack/test/controller/test_case_test.rb') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 05aa4ff6ad..874f9c3c42 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -100,11 +100,11 @@ HTML end def test_xml_output - response.content_type = "application/xml" + response.content_type = params[:response_as] render plain: < - area is an empty tag in HTML, raising an error if not in xml mode +

area is an empty tag in HTML, so it won't contain this content

XML end @@ -374,18 +374,18 @@ XML assert_equal "OK", @response.body end - def test_should_not_impose_childless_html_tags_in_xml - process :test_xml_output + def test_should_impose_childless_html_tags_in_html + process :test_xml_output, params: { response_as: "text/html" } - begin - $stderr = StringIO.new - assert_select "area" #This will cause a warning if content is processed as HTML - $stderr.rewind && err = $stderr.read - ensure - $stderr = STDERR - end + # auto-closes, so the

becomes a sibling + assert_select "root > area + p" + end + + def test_should_not_impose_childless_html_tags_in_xml + process :test_xml_output, params: { response_as: "application/xml" } - assert err.empty?, err.inspect + # is not special, so the

is its child + assert_select "root > area > p" end def test_assert_generates -- cgit v1.2.3