Skip to content
Open
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
13 changes: 13 additions & 0 deletions lib/quickdraw/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def assert_equal_sql(actual, expected)

assert(actual == expected) do
diff = DIFFER.diff_sql(actual, expected)
diff = DIFFER.diff_strings(actual, expected) if no_syntactic_changes?(diff)

"Expected SQL strings to be equal (compared with `actual == expected`):\n\n#{diff}"
end
Expand All @@ -35,6 +36,7 @@ def assert_equal_html(actual, expected)

assert(actual == expected) do
diff = DIFFER.diff_html(actual, expected)
diff = DIFFER.diff_strings(actual, expected) if no_syntactic_changes?(diff)

"Expected HTML strings to be equal (compared with `actual == expected`):\n\n#{diff}"
end
Expand All @@ -47,6 +49,7 @@ def assert_equal_ruby(actual, expected)

assert(actual == expected) do
diff = DIFFER.diff_ruby(actual, expected)
diff = DIFFER.diff_strings(actual, expected) if no_syntactic_changes?(diff)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we'd use diff_objects here we'd also see the diff in whitespace, but I feel like it's not super nice to look at:

CleanShot 2025-01-28 at 23 47 19@2x


"Expected Ruby strings to be equal (compared with `actual == expected`):\n\n#{diff}"
end
Expand Down Expand Up @@ -151,4 +154,14 @@ def refute_same(actual, expected)
"expected #{actual.inspect} not to be the same object as #{expected.inspect}"
end
end

private

def syntactic_changes?(diff)
!no_syntactic_changes?(diff)
end

def no_syntactic_changes?(diff)
diff.include?("No syntactic changes.")
end
end