GithubHelp home page GithubHelp logo

phpspec / phpspec Goto Github PK

View Code? Open in Web Editor NEW
1.9K 1.9K 275.0 4.91 MB

SpecBDD Framework for PHP

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

License: Other

PHP 82.73% HTML 0.51% Smarty 0.06% Gherkin 16.69%
hacktoberfest

phpspec's Introduction

phpspec

The main website with documentation is at http://www.phpspec.net.

Main Build Status

Master Scrutinizer Quality Score

AppVeyor build status

Total downloads

Latest stable version

Latest unstable version

Software license

Installing Dependencies

Dependencies are handled via composer:

wget -nc https://getcomposer.org/composer.phar
php composer.phar install

Developer's mailing list

For development discussion subscribe to [email protected].

Community

Check out #phpspec on irc.freenode.net.

phpspec's People

Contributors

avant1 avatar carlosv2 avatar chris-kruining avatar ciaranmcnulty avatar cordoval avatar ddziaduch avatar docteurklein avatar drupol avatar elfiggo avatar everzet avatar gquemener avatar grahamcampbell avatar greg0ire avatar ifdattic avatar jakzal avatar m-takagi avatar marcelloduarte avatar marek-pietrzak-tg avatar mlopes avatar naomigo avatar padraic avatar pamil avatar richardmiller-zz avatar sam-burns avatar shanethehat avatar sroze avatar stof avatar tswicegood avatar unfunco avatar whatthejeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpspec's Issues

Keep getting "Could not include file"

Hello,

I am trying to run in Windows 7 environment using the PHPSpec source code instead of pear. I created NewBowlingGameSpec.php as in the readme file and saved in location that also contained PHPSpec folder (from src of release). I put a phpspec.php in the same folder as shown below. Finally, I made a run.bat in the same folder with the contents below. When I envoke it as follows
C:\work\test\tests>run NewBowlingGameSpec.php
phpspec: Could not include file "C:\work\test\tests\NewBowlingGameSpec.php/NewBowlingGameSpec.php"

What am I doing wrong? Thanks in advance.

File phpspec.php

!/usr/bin/php

registerNamespace('PHPSpec', ROOT_PATH); $loader->register(); $phpspec = new \PHPSpec\PHPSpec($argv); $phpspec->execute(); ## File run.bat @echo off php phpspec.php %*

Mocks are not evaluated if spec fails

When the spec fails, message is shown that the spec failed.

But showing the mockery messages helps to find out why the spec failed. So it is important to evaluate the mocks even if the spec failed.

0 examples error

cordoval@ms:~/sites-2/FormModelProjectBundle/src/Cordova/Bundle/PhpSpecBundle/Description$ phpspec NewBowlingGame.php -c -b

Finished in 0.000943 seconds
0 examples

Messages disappeared after move to namespaces

Failures, pending and errors should display a message explaining it

Expected:
bossa:spec md$ phpspec StringCalculatorSpec.php

F

Failures:
1)
'string calculator returns zero with no arguments' FAILED
expected 2, got 0 (using be())
/Users/md/Documents/Lab/phpspec/spec/StringCalculatorSpec.php:10

Finished in 0.006172 seconds

1 examples, 1 failure

Actual:
F

Failures:

Finished in 0.010726 seconds

1 examples, 1 failure

Class '\PHPSpec\Runner\Reporter\Console' not found

When running phpspec I see:
$ phpspec MySpec.php
PHP Fatal error: Class '\PHPSpec\Runner\Reporter\Console' not found in /usr/share/php/PHPSpec/Runner.php on line 91
$

OS: Ubuntu 9.10
PHP: 5.3.2

The code where the error happens is:
85: if (isset($options->reporter)) {
86: $reporterClass = "\PHPSpec\Runner\Reporter" .
87: ucfirst($options->reporter);
88: } else {
89: $reporterClass = "\PHPSpec\Runner\Reporter\Text";
90: }
91: $reporter = new $reporterClass($result);

This works fine with PHP 5.3.3 in MacOSX
I tried using reflection and using single quote instead of double. Because "reporter" is coming from the cli arguments it is given as a string, so no chance of pass the object directly. Eval works, but I'd rather not use it.

Maybe the solution would be a switch statement. Since it is already limited to the namespace \PHPSpec\Runner\Reporter anyway.

Better Junit formatter

we need more info about the examples:

  • start time/end time/duration
    we need to know how many expectations are in a suite (example group or explicit suite)
    we need an option to specify a suite explicitly --junit-suite
    --formatter junit
    --junit-suite "Application:./application"
    --junit-suite "Library:./library"
    we need to know the number of examples in a suite
    we need to know the number of failures/errors in a suite
    we need to know which line does the example starts
    one object (reporterEvent) all info, rather than many arguments in the observer

[feature] Display usage with --help or -h

my@prompt $ phpspec --help

Expected:
Usage: phpspec (FILE|DIRECTORY) + [options]
-c, --colour, --color Show coloured (red/green) output
-a, --autospec Run all tests continually, every 10 seconds
-h, --help Print this message
--version Show version
my@prompt $

Load bootstrap file

If a file named phpspec_bootstrap.php exists in the current directory, then load the file first before running any examples.

Is there a way to display test (example) related data on webrunner

I am trying to display additional data (beyond just pass/fail) as part of each example in webrunnber either unconditionally or conditionally (if passed or failed). Is there a way to do that?

In addition, I would like this additional data to be formatted with something like Krumo. Can Krumo be incorporated as part of the webrunner display?

Unable to install via PEAR

I am unable to install PHPSpec with PEAR.

Here's the error:

[root@localhost ~]# pear channel-discover pear.phpspec.net
Adding Channel "pear.phpspec.net" succeeded
Discovery of channel "pear.phpspec.net" succeeded
[root@localhost ~]# pear install phpspec/PHPSpec

Notice: unserialize(): Error at offset 0 of 418 bytes in PEAR/REST/10.php on line 288
PHP Notice: unserialize(): Error at offset 0 of 418 bytes in /usr/share/pear/PEAR/REST/10.php on line 288
PHP Stack trace:
PHP 1. {main}() /usr/share/pear/pearcmd.php:0
PHP 2. PEAR_Command_Common->run() /usr/share/pear/pearcmd.php:305
PHP 3. PEAR_Command_Install->doInstall() /usr/share/pear/PEAR/Command/Common.php:271
PHP 4. PEAR_Downloader->download() /usr/share/pear/PEAR/Command/Install.php:661
PHP 5. PEAR_Downloader_Package->initialize() /usr/share/pear/PEAR/Downloader.php:279
PHP 6. PEAR_Downloader_Package->_fromString() /usr/share/pear/PEAR/Downloader/Package.php:190
PHP 7. PEAR_Downloader->_getPackageDownloadUrl() /usr/share/pear/PEAR/Downloader/Package.php:1713
PHP 8. PEAR_REST_13->getDownloadURL() /usr/share/pear/PEAR/Downloader.php:850
PHP 9. PEAR_REST_10->_returnDownloadURL() /usr/share/pear/PEAR/REST/13.php:142
PHP 10. unserialize() /usr/share/pear/PEAR/REST/10.php:288
SECURITY ERROR: package in channel "pear.phpspec.net" retrieved another channel's name for download! ("pear.php.net")
install failed
[root@localhost ~]#

Environment:

  • OS: CentOS 6.2

PHP 5.3.3 (cli) (built: Jan 11 2012 19:53:01)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.3, Copyright (c) 2002-2012, by Derick Rethans

PEAR Version: 1.9.4
PHP Version: 5.3.3
Zend Engine Version: 2.3.0
Running on: Linux localhost.localdomain 2.6.32-220.4.1.el6.x86_64 #1 SMP Tue Jan 24 02:13:44 GMT 2012 x86_64

Thanks.

Class '\PHPSpec\Runner\Example' not found

When running phpspec I see:
$ phpspec MySpec.php
PHP Fatal error: Class '\PHPSpec\Runner\Example' not found in /usr/share/php/PHPSpec/Runner/Collection.php on line 163
$

OS: Ubuntu 9.10
PHP: 5.3.2

This happens after applying the fix in [gh-6] and is a similar issue in another place and can be probably be solved with a similar strategy.

Returns invalid exampleGroupName if a file with same filename was loaded from separate folder

Say I have these files

specs/
--Something
----TestSpec.php
--Another
----TestSpec.php

Contents of specs/Something/TestSpec.php

<?php
namespace tests\Something;

class DescribeTest extends \PHPSpec\Context {
    ...
}

Contents of specs/Another/TestSpec.php

<?php

class DescribeTest extends \PHPSpec\Context {
    ...
}

This causes the test loader to specify the name of the class name for both example group as the class name from the first file loaded. This was detected in a failing test now marked as pending. Don't know if this causes any trouble in actual usage.

using $this->spec(array('a'))->should->beArray() results in autoloading a.php

Using this piece of code (spec + bootstrap): https://gist.github.com/1224362

The cli runner exits with a fatal error. The list of classes between the cli execution an the fatal error is a simple print call on $sClass in the bootstrap's autoload closure.

xenji@fargate:~/Development/Checkouts/epress/test/specs$ phpspec . 
Mockery
Mockery\Container
ePress\Impl\Autoloader\DefaultConfiguration
ePress\API\Autoloader\Configuration
Mockery\Generator
Mockery\MockInterface
Mockery\Configuration
Mockery\CompositeExpectation
Mockery\ExpectationDirector
Mockery\Expectation
ePress\Impl\DefaultAutoloader
ePress\API\Autoloader
.a
PHP Fatal error:  {closure}(): Failed opening required 'a.php' (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/home/xenji/Development/Checkouts/epress/backend/library:/home/xenji/Development/Checkouts/epress/frontend/library:/home/xenji/Development/Checkouts/epress/shared/library:/test:/test2') in /home/xenji/Development/Checkouts/epress/test/specs/bootstrap.php on line 15

Fatal error: {closure}(): Failed opening required 'a.php' (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/home/xenji/Development/Checkouts/epress/backend/library:/home/xenji/Development/Checkouts/epress/frontend/library:/home/xenji/Development/Checkouts/epress/shared/library:/test:/test2') in /home/xenji/Development/Checkouts/epress/test/specs/bootstrap.php on line 15

Any clues, why it wants to load the content of the array as an object?

Feature request: Support for shared examples

Would be really great to have shared examples support.

class SharedExamplesForAllEditions {
       function itShouldBehaveLikeAllEditions() {
       ...
       }
}
class DescribeSmallEdition {
      var $itShouldBehaveLike = array('all editions');

      function itShouldAlsoBehaveLikeASmallEdition () { ... }
}
class DescribeLargeEdition {
      var $itShouldBehaveLike = array('all editions');

      function itShouldAlsoBehaveLikeALargeEdition () { ... }
}

Just like rspec:

https://www.relishapp.com/rspec/rspec-core/v/2-8/docs/example-groups/shared-examples

[feature] Matcher for throwException

When passing a closure to $this->spec(), a PHPSpec\Specification\Exception object is created in which you can use PHPSpec DSL

    function itShouldComplainWhenNotEmptyAndNoNumbersAreGiven() {
        $this->spec(function () {
             $this-calculator("dfsdf")
         })->should->throwException('InvalidArgumentException', 'No numbers given');
    }

Refactor spec/WorldBuilder.php

This file is used to create a fake World for testing. The problem is the way it is done now, means manually changing a lot of arrays and going through a non-intuitive process in order for tests not to fail when adding new CLI options to PHPSpec.

This file doesn't contain tests and shouldn't influence the test results, it would be nice to have an easier and more intuitive way to add new CLI options to the World object.

[bug] matcher is not valid callback

Matcher is not being created properly under PHP 5.3.2 due to a bug in which namespaced classes cannot be constructed with strings.

Expected:

$ phpspec StringCalculatorSpec.php
.

Finished in 0.009191 seconds

1 examples, 0 failures

Actual:

$ phpspec StringCalculatorSpec.php
EPHP Notice: Undefined index: file in /usr/share/php/PHPSpec/Runner/Example/Exception.php on line 92
PHP Notice: Undefined index: line in /usr/share/php/PHPSpec/Runner/Example/Exception.php on line 92

Errors:

'string calculator returns zero with no arguments' ERROR
call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
:
/usr/share/php/PHPSpec/Specification.php:402
/usr/share/php/PHPSpec/Specification.php:155

Finished in 0.005645 seconds

1 examples, 0 failures, 1 error

HTTP Runner Output doesn't show in Windows

I've traced this back to the writing to php://stdout, which doesn't appear to be working in Windows. I was able to get around this by sticking an echo inside Stdout::put(), but I don't know if that is a solution worth using.

Is there a reason stdout has been used everywhere instead of an echo?

Custom Matchers don't seem to work

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) */

Direct property access was not properly intercepted

Consider the following test.

$object = new $this->spec(new TestSubject());

$object->testProperty->should->be('Default Value');

The code above caused the following error:

PHP Notice: Trying to get property of non-object

Because the interceptor was not returning an object but the value of $object->testProperty.

beOfType from docs doesn't exist

I used beOfType, a matcher mentioned in the docs but didn't exist in the source.

Using this didn't throw an error but showed the spec as passed.

SpecContext ClassLoader path registration

Been a while since I had time to tinker with the code but was trying to get the spec and feature tests running before I start. Had a few issues that I have submitted pull requests for with the specs but wanted to query the features configuration before moving forward.

The SpecContext defines a UniversalClassLoader and registers a namespace and path. However the path being registered is the expected install path. I'm confused about the requirement to have installed PHPSpec to run the tests. Would it be more appropriate to use the local path to the checkout in this instance?

This would allow the following:

  • Stable install from pear plus isolated development code with tests run against it.
  • Simpler setup for active development no need to symlink or similar.
  • No risk of testing PHPSpec with an older pear install file set.

"should->beWhatever()" always returning true

I have the following code:

class Thing {
    public function isStupid() { return FALSE; }
    public function isCool() { return FALSE; }
}

class DescribeThing extends \PHPSpec\Context {

    protected $thing;

    public function before()
    {
        $this->thing = new Thing;
        $this->thingspec = $this->spec($this->thing);
    }

    public function itShouldBeStupid()
    {
        $this->thingspec->should->beStupid();
    }

    public function itShouldNotBeCool()
    {
        $this->thingspec->should->isCool();
    }

}

Both these tests always pass, whether it is should/shouldNot or the results are true/false. Is there something missing here?

When starting a example with uppercase It we see no error

If we use It instead of it no tests are ran for the specified example.

For example, the following code will fail to output a spec failure even though the tested class doesn't exist:

public function ItReturnsZeroWithNoArguments()
{
    $this->spec(StringCalculator::add())->should->be(0);
}

Expected output:

PHP fatal error: Class 'StringCalculator' not found

or

A warning saying the example should start with "it" small caps

or

Accept "it" case insensitive since PHP doesn't enforce case sensibility for method names.

Decoupling matchers

Currently it's not possible to add a directory of matchers to PHPSpec.

PHPSpec_Zend matchers are added in PHPSpec code (hardcoded).

We want a way to add matchers via configuration.

this is an example, similar to the way it's done in rspec:

\PHPSpec\Runner::configure($config)
$config->includeMatchers('/path/to/matchers');
end

Fatal error Html::put() declared twice

PHP Fatal error: Cannot redeclare PHPSpec\Runner\Formatter\Html::put() in /Users/ali/src/phpspec/src/PHPSpec/Runner/Formatter/Html.php on line 326

Fatal error: Cannot redeclare PHPSpec\Runner\Formatter\Html::put() in /Users/ali/src/phpspec/src/PHPSpec/Runner/Formatter/Html.php on line 326

Call Stack:
0.0285 654008 1. {main}() /usr/bin/phpspec:0
0.1251 1462496 2. PHPSpec\PHPSpec->execute() /usr/bin/phpspec:184
0.1251 1462496 3. PHPSpec\PHPSpec->loadAndRun() /Users/ali/src/phpspec/src/PHPSpec/PHPSpec.php:126
0.1281 1697448 4. PHPSpec\Runner\Cli\Runner->run() /Users/ali/src/phpspec/src/PHPSpec/PHPSpec.php:143
0.3134 2160256 5. PHPSpec\Runner\Cli\Runner->runExamples() /Users/ali/src/phpspec/src/PHPSpec/Runner/Cli/Runner.php:123
0.8722 12296528 6. PHPSpec\Specification\ExampleRunner->run() /Users/ali/src/phpspec/src/PHPSpec/Runner/Cli/Runner.php:144
0.8722 12296528 7. PHPSpec\Specification\ExampleRunner->runExamples() /Users/ali/src/phpspec/src/PHPSpec/Specification/ExampleRunner.php:82
0.8723 12300560 8. PHPSpec\Specification\Example->run() /Users/ali/src/phpspec/src/PHPSpec/Specification/ExampleRunner.php:157
0.8728 12301272 9. call_user_func() /Users/ali/src/phpspec/src/PHPSpec/Specification/Example.php:84
0.8728 12301272 10. Spec\PHPSpec\Runner\Formatter\DescribeFormatterFactory->itRecogniseBuiltInFormatters() /Users/ali/src/phpspec/src/PHPSpec/Specification/Example.php:84
0.8779 12716752 11. PHPSpec\Specification\Interceptor\Object->create() /Users/ali/src/phpspec/spec/Runner/Formatter/FormatterFactorySpec.php:22
0.8779 12717384 12. PHPSpec\Specification\Interceptor\Object->__call() /Users/ali/src/phpspec/spec/Runner/Formatter/FormatterFactorySpec.php:22
0.8780 12718096 13. call_user_func_array() /Users/ali/src/phpspec/src/PHPSpec/Specification/Interceptor/Object.php:67
0.8780 12718712 14. PHPSpec\Runner\Formatter\Factory->create() /Users/ali/src/phpspec/src/PHPSpec/Specification/Interceptor/Object.php:67
0.8780 12719480 15. PHPSpec\Loader\UniversalClassLoader->loadClass() /Users/ali/src/phpspec/src/PHPSpec/Specification/Interceptor/Object.php:0

phpspec does not detect installation of mockery from PEAR

I have installed PHPSpec and Mockery using PEAR, but when I use $this->mock() in any test the following error occurs:

PHPSpec\Exception: Mockery is not installed

This is becuase the Mockery class is not in a namespace, when PHPSpec uses the UniversalClassLoader the namespace is not registered and even if you register the namespace Mockery, the loader only starts looking from the Mockery folder onwards.

I have used:

include_once 'Mockery.php';
$loader->registerNamespace('Mockery', '/usr/share/php');

as a workaround.

Inline configuration should override config file options

I have put a .phpspec file in my test folder which holds the following

--bootstrap
bootstrap.php

But for some tests, because of a conflicting (not well thought out) library, I need a separate bootstrap file for some tests. So I run php spec with:

phpspec SomeSpec.php --bootstrap bootstrapmongo.php

But this loads the bootstrap file specified in the .phpspec file.

Add support for constraints or equivalent

At present phpspec does not appear to support anything equivalent to the 'constraint' functionality provided by phpunit but sometimes fuzzy matches are required when testing arguments passed to mocked methods.

As an example use case consider the regular expression example below or in a situation where multiple arguments are passed to a mocked method but you only need to verify one (in which case you would use the 'anything' constraint).

http://www.phpunit.de/manual/3.4/en/api.html#api.assert.assertThat.tables.constraints documents all constraints that PHPUnit supports.

Here is an example of the constraints functionality.

<?php

class SomeObject
{
    public function someMethod( $arg1, $arg2 )
    {
    }
}

class TestCase extends PHPUnit_Framework_TestCase
{
    public function setup()
    {
        $this->mock = $this->getMock( 'SomeObject' );
        $this->mock->expects( $this->any() )
            ->method( 'someMethod' )
            ->with(
                $this->matchesRegularExpression( '/^abc.*/' ),
                $this->greaterThan( 4 )
            );
    }

    public function testConstraintPassExample()
    {
        $this->mock->someMethod( 'abc123', 5 );
    }

    public function testFirstArgConstraintFailExample()
    {
        $this->mock->someMethod( 'def456', 6 );
    }

    public function testSecondArgConstraintFailExample()
    {
        $this->mock->someMethod( 'abc456', 2 );
    }
}

Unable to reflect Interrogator Class in Specification

PHPSpec installed with PEAR on Ubuntu 10.04

PHP5 package from XAMPP for Linux 1.7.4


Using the tutorial Bowling class and specification file, I get the following:

  1. NewBowling should score0 for gutter game
    Failure/Exception: $class = new \ReflectionClass("\PHPSpec\Object\Interrogator");
    ReflectionException: Class \PHPSpec\Object\Interrogator does not exist

    /usr/share/php/PHPSpec/Specification.php:121

    /usr/share/php/PHPSpec/Context.php:87

    ./DescribeNewBowling.php:12

dot phpspec

World::loadConfig() loads several config files, though, the contents
in the configs affect nothing.
In the method, it does:
$configArguments = file($localConfig);
...
$this->_options = array_merge($this->_options, $configArguments);
file() returns array with numeric keys, but $this->_options expects
associated array.
I think parse_ini_file() would suit more in that context.
And more,

public function loadConfig() 
{ 
    $ds          = DIRECTORY_SEPARATOR; 
    $localConfig =       getcwd() . $ds . '.phpspec'; 
    $homeConfig  = getenv('HOME') . $ds . '.phpspec'; 
    $etcConfig   =    $ds . 'etc' . $ds . 'phpspec' . $ds . 'phpspec.conf'; 
    $configArguments = array(); 
    if (file_exists($localConfig)) { 
        $configArguments = file($localConfig); 
    } elseif (file_exists($homeConfig)) { 
        $configArguments = file($homeConfig); 
    } elseif (file_exists($etcConfig)) { 
        $configArguments = file($etcConfig); 
    } 
    $this->_options = array_merge($this->_options, $configArguments); 
} 

It will load only one from candidate config files.
But I think it'd be more preferable if it merges in order of
etc -> home -> local.

[feature] Define matchers on the fly

It should be possible to define matchers on the fly

\PHPSpec\Matchers\define('contain', function($match, $actual) {
    return in_array($match, $actual);
});

class MyArraySpec extends \Context\PHPSpec {
    function itAddsNewElementsUsingArrayOperator() {
        $array = new MyArray();
        $array[] = 42;
        $array->should->contain(42);
    }
}

Textmate formatter

This is similar to a Html formatter, only it outputs a textmate friendly page, similar to what's available in other textmate bundles.

It's also required to write a tmbundle to test this.

Too much recursion

Fatal error: Nesting level too deep - recursive dependency? in /home/likewise-open/ALLIEDINSURE/amjad/src/phpspec/src/PHPSpec/Matcher/Equal.php on line 150

This is happening when I run the following test.

public function itShouldSpecifyFilters() {
    $this->query->whereProperty('name')->isEqualTo('The Name');

    $this->query->getWheres()->should->equal('a');
}

$this->query is a spec wrapping my SimDAL_Query object.

You can get the source from and run the tests from bdd branch.

Run the tests/PHPSpec/AllSpecs.php file from the browser. I couldn't find a way to bootstrap the tests before running so I had only setup the http runner. Although PHPSpec tries to load config from .phpspec?

Also the file has the path to PHPSpec hard coded.

Anyway could you check this issue?

Empty examples are read as pending

At the moment if an example is empty it is marked as pass by the progress formatter.

Empty examples should be considered pending, so developers can know they are unfinished.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.