Skip to content

Commit 6e8b754

Browse files
authored
Merge pull request #110 from nicoco007/fix-substitution-regression
Fix string substitution regression
2 parents f8b8e05 + 1d9394c commit 6e8b754

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def matcher_for(value, format_for_presentation)
2626
# Nokogiri doesn't like arbitrary values without quotes, hence inspect.
2727
if format_for_presentation
2828
value.inspect # Avoid to_s so Regexps aren't put in quotes.
29-
else
29+
elsif value.is_a?(Regexp)
3030
"\"#{value}\""
31+
else
32+
value.to_s.inspect
3133
end
3234
end
3335

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)