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

Fixup issue with multiline diffs in custom matchers. #423

Merged
merged 2 commits into from
Feb 6, 2014

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Jan 12, 2014

Fix #420 by not forcing expected to be an array in custom matchers.

@JonRowe
Copy link
Member Author

JonRowe commented Jan 12, 2014

I''d like a review on this to make sure its a sensible strategy for solving this problem. /cc @myronmarston

@myronmarston
Copy link
Member

Yep, planning to review this tonight. I'm out most of the afternoon.

@no_array = true
@expected = expected[0]
else
@no_array = false
Copy link
Member

Choose a reason for hiding this comment

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

What is @no_array meant to be used for? I see it set here but never used again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Was for something that later proved unnecessary...

@myronmarston
Copy link
Member

This looks like a reasonable fix, although it doesn't demonstrate adequately that it fixes the diff issue since there's no spec here demonstrating that the diff is the same for a custom matcher as for a matcher like eq. What do you think of bringing over the spec I wrote up in #420? That would help demonstrate this fixes the bug and also guard against future regressions since the diffing behavior of custom matchers is an important behavior to maintain in future releases.

@JonRowe
Copy link
Member Author

JonRowe commented Jan 14, 2014

Added a spec, it's not quite as simple as proposed in #420 cause ASCII control codes...

@myronmarston
Copy link
Member

LGTM.

@JonRowe
Copy link
Member Author

JonRowe commented Jan 14, 2014

I'd like to hold off till I get a chance to look at the behaviour of expected/actual a bit more actually, I got a weird diff with true/false when playing around with the sample custom matcher.

@myronmarston
Copy link
Member

What's an example of where this produces a weird diff?

@JonRowe
Copy link
Member Author

JonRowe commented Jan 20, 2014

@JonRowe
Copy link
Member Author

JonRowe commented Jan 24, 2014

Did you get a chance to look at the weird diff?

@myronmarston
Copy link
Member

Not yet, sorry, thanks for the reminder.

@JonRowe
Copy link
Member Author

JonRowe commented Feb 6, 2014

Ping?

@myronmarston
Copy link
Member

So, looking at your example, I think the diff from before is weird, and the new behavior with this change (e.g. no diff) is correct. What do you think is weird about it?

@JonRowe
Copy link
Member Author

JonRowe commented Feb 6, 2014

I'm ok with the lack of diff on the true/false but note that the strings aren't being diffed either...

@myronmarston
Copy link
Member

I'm ok with the lack of diff on the true/false but note that the strings aren't being diffed either...

We only provide diffs when there are multiline strings involved:

if any_multiline_strings?(actual, expected)
message << "\nDiff:" << differ.diff_as_string(coerce_to_string(actual), coerce_to_string(expected))
end

Your example did not provide multiline strings so I would not expect a diff.

@JonRowe
Copy link
Member Author

JonRowe commented Feb 6, 2014

Fair enough

@JonRowe
Copy link
Member Author

JonRowe commented Feb 6, 2014

Merging because the rbx build issue is separate.

JonRowe added a commit that referenced this pull request Feb 6, 2014
…n_custom_matchers

Fixup issue with multiline diffs in custom matchers.
@JonRowe JonRowe merged commit 0a961b5 into master Feb 6, 2014
@JonRowe JonRowe deleted the fixup_issue_with_multiline_diffs_in_custom_matchers branch February 6, 2014 22:27
@myronmarston
Copy link
Member

You still planning to add a deprecation warning to 2.99 for this?

@JonRowe
Copy link
Member Author

JonRowe commented Feb 6, 2014

Yeah on my list

@JonRowe JonRowe restored the fixup_issue_with_multiline_diffs_in_custom_matchers branch February 9, 2014 22:31
@JonRowe JonRowe deleted the fixup_issue_with_multiline_diffs_in_custom_matchers branch February 9, 2014 22:32
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.

Diff from diffable custom matcher does not handle multiline string properly
2 participants