Modified: branches/zend/specs/ContextZendSpec.php (202 => 203)
--- branches/zend/specs/ContextZendSpec.php 2008-01-16 16:42:46 UTC (rev 202)
+++ branches/zend/specs/ContextZendSpec.php 2008-01-16 17:35:15 UTC (rev 203)
@@ -158,6 +158,15 @@
$response->shouldNot->beSuccess();
}
+ public function itShouldAttachHavetextMatcherToResponse()
+ {
+ $context = new DescribeFooController;
+ $response = new PHPSpec_Context_Zend_Response;
+ $response->setContext($context);
+ $response->setBody('I Am Text');
+ $response->should->haveText('I Am Text');
+ }
+
public function after()
{
PHPSpec_Context_Zend::clearModuleDirectories();
Added: branches/zend/src/PHPSpec/Context/Zend/Matcher/HaveText.php (0 => 203)
--- branches/zend/src/PHPSpec/Context/Zend/Matcher/HaveText.php (rev 0)
+++ branches/zend/src/PHPSpec/Context/Zend/Matcher/HaveText.php 2008-01-16 17:35:15 UTC (rev 203)
@@ -0,0 +1,51 @@
+<?php
+/**
+ * PHPSpec
+ *
+ * LICENSE
+ *
+ * This file is subject to the GNU Lesser General Public License Version 3
+ * that is bundled with this package in the file LICENSE.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.gnu.org/licenses/lgpl-3.0.txt
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to lic...@phpspec.org so we can send you a copy immediately.
+ *
+ * @category PHPSpec
+ * @package PHPSpec
+ * @copyright Copyright (c) 2007 Pádraic Brady, Travis Swicegood
+ * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
+ */
+
+/**
+ * @category PHPSpec
+ * @package PHPSpec
+ * @copyright Copyright (c) 2007 Pádraic Brady, Travis Swicegood
+ * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
+ */
+class PHPSpec_Context_Zend_Matcher_HaveText extends PHPSpec_Matcher_Match
+{
+
+ public function __construct($expected)
+ {
+ // this is of course total bullshit for HTML but first things first
+ $this->_expected = "/" . str_replace('/', '\/', $expected) . "/";
+ }
+
+ public function getFailureMessage()
+ {
+ return 'expected match for /' . strval($this->_expected) . '/, but got no matching text (using haveText())';
+ }
+
+ public function getNegativeFailureMessage()
+ {
+ return 'expected no match for /' . strval($this->_expected) . '/, but got matching text (using haveText())';
+ }
+
+ public function getDescription()
+ {
+ return 'have text of ' . strval($this->_expected);
+ }
+
+}
\ No newline at end of file
Modified: branches/zend/src/PHPSpec/Specification.php (202 => 203)
--- branches/zend/src/PHPSpec/Specification.php 2008-01-16 16:42:46 UTC (rev 202)
+++ branches/zend/src/PHPSpec/Specification.php 2008-01-16 17:35:15 UTC (rev 203)
@@ -124,7 +124,7 @@
$matchers = array(
'equal', 'be', 'beEqualTo', 'beAnInstanceOf', 'beGreaterThan', 'beTrue', 'beFalse', 'beEmpty', 'beLessThan', 'beGreaterThanOrEqualTo', 'beLessThanOrEqualTo', 'beSet', 'beNull', 'beOfType', 'beIdenticalTo', 'match', 'throw',
- 'beSuccess'
+ 'beSuccess', 'haveText'
);
if (in_array($method, $matchers)) {
$this->setExpectedValue(array_shift($args));