Skip to content

Commit 55fd781

Browse files
authored
Merge pull request #106 from flavorjones/flavorjones-better-failure-diff
Use Minitest::Assertion#diff for content failure messages
2 parents 8deceed + a7157c2 commit 55fd781

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def document_root_element
275275
def assert_size_match!(size, equals, css_selector, message = nil)
276276
min, max, count = equals[:minimum], equals[:maximum], equals[:count]
277277

278-
message ||= %(Expected #{count_description(min, max, count)} matching "#{css_selector}", found #{size}.)
278+
message ||= %(Expected #{count_description(min, max, count)} matching #{css_selector.inspect}, found #{size})
279279
if count
280280
assert_equal count, size, message
281281
else

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
class HTMLSelector #:nodoc:
55
attr_reader :css_selector, :tests, :message
66

7+
include Minitest::Assertions
8+
79
def initialize(values, previous_selection = nil, &root_fallback)
810
@values = values
911
@root = extract_root(previous_selection, root_fallback)
@@ -52,7 +54,7 @@ def filter(matches)
5254
content.sub!(/\A\n/, '') if text_matches && match.name == "textarea"
5355

5456
next if regex_matching ? (content =~ match_with) : (content == match_with)
55-
content_mismatch ||= sprintf("<%s> expected but was\n<%s>", match_with, content)
57+
content_mismatch ||= diff(match_with, content)
5658
true
5759
end
5860

0 commit comments

Comments
 (0)