-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Strict predicate matchers #1102
Comments
Hi, Have you considered implementing your own custom matcher that does what you want? |
Yeah, we'll probably continue using the more precise syntax for now. Might end up looking into custom matchers at some point. |
@JonRowe Could you revisit this please?
I don't believe this is accurate. For example, the doc gives the following example:
Lacking from the doc: "but with a less strict matcher corresponding to All examples given return The doc clearly shows that the failure messages are also deceiving. When we get the following errors, how can we possibly expect the check to be truthy/falsy?
I feel that these matchers are imprecise and error prone. A method returning Assuming you still like the imprecise matchers, I would propose:
I will glady provide a PR for this.
It's a really bad option, as it makes the spec less readable and the error messages much less informative |
Given the inconsistencies of our current doc with the behaviour, I'm in favour of this proposal. Let's postpone the |
The setting doesn't exist yet; I'm proposing that one is created. I believe the default should be |
I clearly understand that. Once this setting is added, it would be easier to discuss to flip its default, but only during a major version update. |
Oh, sorry, I misread then. So I'll work on a PR then, or did you want to handle it @pirj ? |
It's up to @JonRowe to decide. |
For context, I originally assessed this as a bug report and I lacked (and still lack) the time to implement anything to improve the situation, as it stands it works as designed. However @marcandre @pirj if either of you wants to work on an opt-in config for this matcher to make it stricter I'd be happy to review it. I'm generally a fan of stricter matchers too but I definitely don't want to change the default in 3.x (breaking change). I'd be happy to add a warning in 3.99 and then change the default in 4.x but I'd also want to announce those plans early on to get consensus. |
Awesome, thanks! |
Please open a new PR when you're ready for review, this stays closed. |
Sounds good. 👍 I've slightly changed the wording of the description so it looked more like a feature request than a bug report. |
🎉 Awesome 😃 @pirj let me know if you want to handle this, otherwise I'll check it out in the next few days |
@marcandre Highly appreciate if you can take care of this, I have a reduced capacity those days unfortunately. |
Subject of the issue
It would be great to have a configuration for predicate matchers to be "strict" in the sense that they require the return result to be a boolean and not something that is truthy or falsey. It's easy for these methods to have values that creep their way to the client side in tricky to debug ways, so we try as much as possible in our codebase to enforce that they always return
true
orfalse
. Right now we avoid the predicate matchers and instead useexpect(thing.there?).to be true
.Proposed Solution
The above test should fail with a message
'yep'
instead oftrue
.There should be no changes in behaviour if
strict_predicate_matchers
is explicitly set tofalse
or the default value is used.The text was updated successfully, but these errors were encountered: