diff options
author | Matthew Draper <matthew@trebex.net> | 2016-12-21 04:40:24 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-21 04:40:24 +1030 |
commit | 1bf6acb1ec8395e710d40dc49c476af722418ad4 (patch) | |
tree | 1e3fbf91c2ca2f454abde763d3ba8e0c5562e970 /actionpack | |
parent | 695065281e75d05f942d2a5eb6b203da8d672770 (diff) | |
parent | 86f77894803a6b2dc79d611fa9b51ebc67f1263b (diff) | |
download | rails-1bf6acb1ec8395e710d40dc49c476af722418ad4.tar.gz rails-1bf6acb1ec8395e710d40dc49c476af722418ad4.tar.bz2 rails-1bf6acb1ec8395e710d40dc49c476af722418ad4.zip |
Merge pull request #27414 from matthewd/fix-xml-vs-html-assertion
Revise the "XML is not HTML" test
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 24 |
1 files changed, 12 insertions, 12 deletions
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: <<XML <?xml version="1.0" encoding="UTF-8"?> <root> - <area>area is an empty tag in HTML, raising an error if not in xml mode</area> + <area><p>area is an empty tag in HTML, so it won't contain this content</p></area> </root> 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 + # <area> auto-closes, so the <p> 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 + # <area> is not special, so the <p> is its child + assert_select "root > area > p" end def test_assert_generates |