Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to diff_strings when assert_equal_* has no syntactic changes #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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