Skip to content

Commit

Permalink
Merge pull request #110 from nicoco007/fix-substitution-regression
Browse files Browse the repository at this point in the history
Fix string substitution regression
  • Loading branch information
rafaelfranca authored Aug 3, 2023
2 parents f8b8e05 + 1d9394c commit 6e8b754
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ def matcher_for(value, format_for_presentation)
# Nokogiri doesn't like arbitrary values without quotes, hence inspect.
if format_for_presentation
value.inspect # Avoid to_s so Regexps aren't put in quotes.
else
elsif value.is_a?(Regexp)
"\"#{value}\""
else
value.to_s.inspect
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/selector_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ def test_substitution_values
end
end

def test_substitution_value_with_quotes
render_html '<input placeholder="placeholder with &quot;quotes&quot;" />'
assert_select "input[placeholder=?]", 'placeholder with "quotes"'
end

def test_multiple_substitution_values
render_html '<input name="foo[12]" value="34">'
assert_select ":match('name', ?):match('value', ?)", /\w+\[\d+\]/, /\d+/
Expand Down

0 comments on commit 6e8b754

Please sign in to comment.