-
-
Save everzet/981759 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
Why i think, that "RSpec is not possible in PHP"? | |
Cuz Ruby's syntax abilities can represent | |
natural language constructions: | |
object should equals 2 | |
almost without changes in specs: | |
object.should == 2 || object.should equals(2) | |
but PHP: */ | |
$this->spec($object)->should()->be(2); | |
/* does NOT! | |
And what's even worse - this construction | |
is far less readable, than more natural in | |
php assertions: */ | |
$this->assertEquals(2, $object); | |
/* Why? | |
1. Cuz `->` is a READABLE noize in counterpart with non-readable `.`. | |
2. Cuz `$this->method(...)` is not a `method ...` | |
3. Cuz `$this->object` is not a `@object` | |
4. Cuz `$this->spec(...)` doesn't make sense at all in terms of behavior description. | |
It's again - readable noize | |
*/ |
something to consider:
<?php
$this->assert(2)->equals($object);
$this->assert($object)->is(2);
that could be a PHP way of Spec writing
Bottom line is copying syntax from another language should be done with a fair amount of thought, so that it actually simplifies use
@avalanche123 or:
<?php
$this->expect(2)->equals($object);
$this->expect($object)->is(2);
👏
Hi, how do you think about this?
Its matchers are PHPSpec's.
https://github.com/yuya-takeyama/Speciphy
Yes, PHP's syntax sucks, but I don't see anything stopping you from implementing a pre-processor in PHP for syntax something like: https://gist.github.com/1569735 .
Otherwise, good point, see http://mechanicalrobotfish.com/posts/117-ruby-vs-php-bdd-beauty-contest-no-contest if you haven't already.
Though I do think that it would be easier to just teach Ruby to run PHP and to inspect PHP memory state.
lol, this is bananas. @dbernar1 "PHP's syntax" ? that syntax is not unique to PHP buddy.
+1