This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Check for nil instead of truthiness when making a diff #377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous Behavior
The following lines create different output:
The first generates a diff, whereas the second does not. This is because the actual and expected values are checked for presence with
if actual && expected
when creating the diff. In the first example, the actual is true, so it passes the check. In the second, the actual is false and the diff returned is an empty string.New Behavior
These should be consistent with each other. The two options would be to make them both create a diff or modify the matcher so neither do. However, since all other
match(something)
matchers produce a diff output, it makes sense to do the same here.If it is necessary for that check to also check for truthiness, then another solution could be found. But, I cannot find a situation where false would be passed in where we wouldn't want to create a diff.