assert_select_encoded can't handle escaped characters within XML
dnrce opened this issue · 4 comments
Escaped characters within XML (as required by the spec) aren't handled properly by assert_select_encoded. For example, no p element is found within the following:
<element><p>Paragraph text</p></element>The same content using CDATA has no issues.
See https://gist.github.com/dnrce/9e48173bda64ea1ee6ed to reproduce.
This looks like escaped content and not encoded CDATA content. As far as I know, assert_select_encoded is only supposed to work on CDATA elements — see the tests here:
rails-dom-testing/test/selector_assertions_test.rb
Lines 235 to 280 in 46591c7
Escaped content is the default output of the XML builder used by Action View, so it seems like a miss to be unable to test that easily. I'll see if I can write a test case that uses the builder directly.
I should also mention that I ran into this during a Rails 4.2 upgrade -- the version of the method built into Action Pack 4.1 has no trouble with this because it uses CGI.unescapeHTML. So although rails-dom-testing is new in the 4.2 ecosystem, in a way this is a regression.