Skip to content

Conversation

marcoroth
Copy link

When using assert_equal_ruby the diff wouldn't show when you have whitespace differences in the strings you are comparing.

This pull request changes that behavior by falling back to diff_strings when assert_equal_* has no syntactic changes.

Before:
CleanShot 2025-01-28 at 23 06 28@2x

After:

CleanShot 2025-01-28 at 23 40 59@2x

@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant