Skip to content

Commit 1d9394c

Browse files
committed
Special case Regexp instead of strings
1 parent 4d57fce commit 1d9394c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ 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 || value.is_a?(String)
27+
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

0 commit comments

Comments
 (0)