diff --git a/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb b/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
index c062da7..66012b1 100644
--- a/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
+++ b/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
@@ -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
diff --git a/test/selector_assertions_test.rb b/test/selector_assertions_test.rb
index 5f91c56..bc3a2a1 100644
--- a/test/selector_assertions_test.rb
+++ b/test/selector_assertions_test.rb
@@ -136,6 +136,11 @@ def test_substitution_values
end
end
+ def test_substitution_value_with_quotes
+ render_html ''
+ assert_select "input[placeholder=?]", 'placeholder with "quotes"'
+ end
+
def test_multiple_substitution_values
render_html ''
assert_select ":match('name', ?):match('value', ?)", /\w+\[\d+\]/, /\d+/