Skip to content

Commit 4d57fce

Browse files
nicoco007rafaelfranca
authored andcommitted
Fix string substitution regression
1 parent f8b8e05 commit 4d57fce

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def match(matches, attribute, matcher)
2424
private
2525
def matcher_for(value, format_for_presentation)
2626
# Nokogiri doesn't like arbitrary values without quotes, hence inspect.
27-
if format_for_presentation
27+
if format_for_presentation || value.is_a?(String)
2828
value.inspect # Avoid to_s so Regexps aren't put in quotes.
2929
else
3030
"\"#{value}\""

test/selector_assertions_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ def test_substitution_values
136136
end
137137
end
138138

139+
def test_substitution_value_with_quotes
140+
render_html '<input placeholder="placeholder with &quot;quotes&quot;" />'
141+
assert_select "input[placeholder=?]", 'placeholder with "quotes"'
142+
end
143+
139144
def test_multiple_substitution_values
140145
render_html '<input name="foo[12]" value="34">'
141146
assert_select ":match('name', ?):match('value', ?)", /\w+\[\d+\]/, /\d+/

0 commit comments

Comments
 (0)