Add toBeInvokable
arch expectation
#891
Merged
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.
Hey!
This PR is just a small one, but something that I think could be useful for some devs (including myself). This PR proposes a new
toBeInvokable
expectation that can be used to assert whether a class has an__invoke
method.I like to use invokable classes quite a bit (for things like action classes). An example action class might be something like this:
And then it can be called like so in my controller:
I like to follow this pattern and like knowing that all my actions are invokable. So I thought it'd be handy to have an expectation that I can use to enforce this.
The expectation can be used like so:
I'm not entirely sure if I've done everything right here, but I've tried my best to make sure there are tests covering the code. If I've done anything wrong though, please give me a shout!
Likewise, if this is something you think might be useful to other devs but you want something changing first, let me know and I'll get to it ASAP! 😄