Created
May 19, 2011 21:13
-
-
Save everzet/981759 to your computer and use it in GitHub Desktop.
Why RSpec is not possible in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.