Skip to content

Fix string substitution regression #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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