phpspec/phpspec — Issue #43: Custom Matchers don't seem to work
Author: nrocy
Created: 2011-12-01 09:21:55+00:00
State: open

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)

*/