Is there a way to use PHPSpecs matchers independently?

212 views
Skip to first unread message

Adrian Moya

unread,
May 2, 2013, 7:16:41 PM5/2/13
to phpsp...@googlegroups.com
Hi, I recently made an example of StoryBDD using Behat. In this example, I ended installing PHPUnit to use the assertions as described in Behat docs (http://docs.behat.org/quick_intro.html#more-about-steps)

I'll continue my set of examples with SpecBDD using PHPSpec. But being the two projects almost like brothers, or a pair made in heaven, it feels clumsy to have PHPUnit just for assertions, but use PHPSpec to actually design the classes. 

Is there a way to use PHPSpec matchers as assertions for behat's steps definitions? Can anybody provide a code example?

Thanks,

Luis Cordova

unread,
May 3, 2013, 1:43:41 AM5/3/13
to phpsp...@googlegroups.com
if you are using phpunit is because classes were already written
I don't think is a good idea to load phpspec with assertions, you should use phpunit which has a larger framework that can be extended rather and is used for functional tests



--
You received this message because you are subscribed to the Google Groups "PHPSpec - Behavior Driven Design (BDD) for PHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpspec-dev...@googlegroups.com.
To post to this group, send email to phpsp...@googlegroups.com.
Visit this group at http://groups.google.com/group/phpspec-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

md

unread,
May 3, 2013, 2:04:44 AM5/3/13
to phpsp...@googlegroups.com
There is an phpspec extension for that:

https://github.com/MarcelloDuarte/phpspec2-expect

Here is an example of usage with Behat:


Note that a version compatible with the newly release phpspec 2.0.0-BETA1 is not yet available

md

Luis Cordova

unread,
May 3, 2013, 2:06:27 AM5/3/13
to phpsp...@googlegroups.com
nice, thanks md


Luis Cordova

unread,
May 3, 2013, 2:19:58 AM5/3/13
to phpsp...@googlegroups.com

Adrian Moya

unread,
May 3, 2013, 9:54:53 AM5/3/13
to phpsp...@googlegroups.com
Thanks Marcello, this is what I was looking for. I'll check it out, it really makes sense to use PHPSpec instead of PHPUnit.

@Luis, my use of PHPUnit is just for assertions in the last step of the scenarios, to check that a condition is met. Not necessarily means that I'm unit testing classes, just checking that the app rendered a response as I expected. Check out the example at my github page, specifically line 61 of the FeatureContext.php.
Reply all
Reply to author
Forward
0 new messages