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

Add support for custom Throw matchers #1348

Open
toby-griffiths opened this issue Nov 16, 2020 · 5 comments
Open

Add support for custom Throw matchers #1348

toby-griffiths opened this issue Nov 16, 2020 · 5 comments

Comments

@toby-griffiths
Copy link

Currently I don't believe it's possible to add customer Throw matchers that support the during{MethodName}}() type trigger method, since the current code tests whether the method called is should[Not]Throw() (or 'Trigger').

I'm hoping to be able to submit a PR for this shortly that would update the ExpectationFactory to allow for customer matcher that started with 'should[Not]Throw' e.g. should[Not]Throw{Whatever}() (or Trigger) to generate PositiveThrow|NegativeThrow|PositiveTrigger|NegativeTrigger expectations, rather that the default Positive|Negative one.

@ciaranmcnulty
Copy link
Member

Interesting. @drupol implemented something similar that uses during in https://github.com/loophp/phpspec-time

@toby-griffiths
Copy link
Author

Hmmm… interesting. I've had a quick look, but it looks like that library is using the simple during() version of the calls, and also not trying to catch exceptions.

@drupol are you familiar with this issue?

@drupol
Copy link
Contributor

drupol commented Nov 16, 2020

Hi there,

@drupol are you familiar with this issue?

This is indeed the purpose of phpspec-time, just to measure time, nothing else nothing more.

Of course, it's pretty new and it might be incomplete, I guess there are ways to improve it for sure.

@toby-griffiths
Copy link
Author

OK, so to be able to catch exceptions in custom matchers using the during{Method}() type calls would be a useful addition then, by the sound of it.

@drupol
Copy link
Contributor

drupol commented Nov 19, 2020

I think yes :-)

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

No branches or pull requests

3 participants