phpspec / phpspec

SpecBDD Framework for PHP

Home Page:http://www.phpspec.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for custom Throw matchers

toby-griffiths opened this issue · comments

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.

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

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?

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.

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.

I think yes :-)