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

Align Spec::Be, BeClose failure message to other messages #11946

Merged
merged 3 commits into from
Apr 28, 2022

Conversation

jgaskins
Copy link
Contributor

@jgaskins jgaskins commented Mar 28, 2022

The failure message previously had its to_s method called on it, but other expectations use inspect. This was creating failure messages like this:

       Expected 2022-03-28 22:05:06.966811000 UTC to be GreaterThan 2022-03-28 22:05:06 UTC

The failure message previously had its `to_s` method called on it, but
other expectations use `inspect`.
Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

Thanks! I'm adding it to 1.5 just because it might break some existing workflows and I don't want to rush it in 1.4

@beta-ziliani beta-ziliani added this to the 1.5.0 milestone Mar 29, 2022
@asterite
Copy link
Member

This was creating failure messages like this

Sorry that I don't have time to try this, but what's the new failure message?

@jgaskins
Copy link
Contributor Author

Sorry that I don't have time to try this, but what's the new failure message?

New error message is

       Expected 2022-03-29 12:45:07.764260000 UTC to be GreaterThan 2022-03-29 12:45:07.764260000 UTC

We can see from this one that the problem is because the first is not greater than the second because they're equal. The problem with the live one is that 2022-03-28 22:05:06.966811000 UTC is greater than 2022-03-28 22:05:06 UTC, but the error message does not communicate it.

@jgaskins
Copy link
Contributor Author

Thanks! I'm adding it to 1.5 just because it might break some existing workflows and I don't want to rush it in 1.4

@beta-ziliani This makes sense. I never ran into this until yesterday because most of the be_close expectations I've used have been numeric, where to_s and inspect look the same. And, honestly, if it weren't for the fact that macOS only has microsecond precision on the system clock I doubt I would've noticed it on timestamps, either.

I have it monkeypatched in my own spec_helper, so I can wait on it being added to the stdlib. 👍🏼

@asterite
Copy link
Member

Thanks!

As a side note, "GreaterThan" could be changed to "greater than" at some point. I think before moving things to an enum it was "greater_than", which was slightly better though of course not ideal.

@HertzDevil
Copy link
Contributor

It was :">" before the refactor. An exhaustive case or an overridden Relation#to_s will do.

@straight-shoota straight-shoota changed the title Align Spec::Be/BeClose failure message to others Align Spec::Be, BeClose failure message to other messages Apr 28, 2022
@straight-shoota straight-shoota merged commit f3903d2 into crystal-lang:master Apr 28, 2022
@jgaskins jgaskins deleted the patch-2 branch June 24, 2022 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants