Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Custom Matchers don't seem to work #43

Closed
nrocy opened this Issue Dec 1, 2011 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

nrocy commented Dec 1, 2011

My attempt is outlined here: https://gist.github.com/1408521

From limited digging through the phpspec code, it looks as though the matcher is registered but isn't getting called.

in PHPSpec/Specification/Interceptor.php __call method the check that the matcher is in MatcherRespository passes, causing the call to $this->_performMatching(); which appears to cause __call() to be hit again but nothing happens during this iteration.

Thanks

Gist pasted below for ref:

function($actual) use ($match) { return $actual === $match; }, "failure_message_for_should" => function($actual) use ($match) { return "expected {$actual} to be, like, totally equal to {$match}, man"; } ); }); class DescribeTotallyWorks extends \PHPSpec\Context { public function itTotallyWorksWhenItShould() { $this->spec(10)->should->totallyEqualMan(10); } public function itTotallyWorksWhenItShouldnt() { $this->spec(10)->should->totallyEqualMan(11); } public function itHasAWorkingPhpSpec() { $this->spec(10)->should->equal(10); $this->spec(10)->shouldNot->equal(9); } } /* $ phpspec --version 1.2.2beta $ phpspec spec/TotallyWorksSpec.php -f d -c TotallyWorks totally works when it should totally works when it shouldnt <<-- expect this to fail has a working php spec Finished in 0.017361 seconds 3 examples $ pear list -a # Installed packages, channel __uri: (no packages installed) # Installed packages, channel doc.php.net: (no packages installed) # Installed packages, channel hamcrest.googlecode.com/svn/pear: Package Version State Hamcrest 0.3.0 stable # Installed packages, channel pear.php.net: Package Version State Archive_Tar 1.3.8 stable Console_Getopt 1.3.1 stable PEAR 1.9.4 stable Structures_Graph 1.0.4 stable XML_Util 1.2.1 stable # Installed packages, channel pear.phpspec.net: Package Version State PHPSpec 1.2.2beta beta PHPSpec_Mocks 1.1.0beta beta PHPSpec_Zend 1.2beta beta # Installed packages, channel pear.phpunit.de: Package Version State Text_Template 1.1.1 stable # Installed packages, channel pear.survivethedeepend.com: Package Version State Mockery 0.7.1 stable # Installed packages, channel pecl.php.net: (no packages installed) */
Contributor

nrocy commented Dec 1, 2011

I managed to get it working, unsure how to run the phpspec specs, so no pull request yet.

Commit here: nrocy/phpspec@ed3310a

Owner

MarcelloDuarte commented May 14, 2012

@nrocy's code has been added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment