Closed franciscocardoso closed 5 years ago
WTYD @guillaumepotier ?
Hi, thanks for this quite long and explaining issue.
I think this is related somehow with #29 as the original Required
were kinda bloated no? I mean, user should not have a need to override an existing Assert
as they should be atomic (not the case for Require
) and "built-in" right?
We should allow user to define its own Assert, and that should be done in the pretty way too like the others built-in, but not being able to override them does not seem a serious matter to me.
Hi,
Indeed, one thing leads to another. I'll create a PR disallowing override asserts when extending.
Thanks!
Entend
The Assert class can be extended by using the
Extend
feature. Besides adding custom asserts this allows us to override any of the asserts available in the module. Let's say that someone needs to tweak the behaviour of an existing Assert, Required per instance.You can achieve this by doing something like this:
And you are done. At this point you can use your own
Required
assert.Pretty constructors
With the introduction of this feature we can write this with less code, which is awesome. You can simply write:
Problem
The behaviour will be different for each of the calls.
This is due to the cache mechanism added to the _prettify method which prevents any existing Assert from being overridden.
Solutions
I believe that the solution will depend on the desired behaviour.
How should we approach this issue?