Skip to content

Instantly share code, notes, and snippets.

@phpspec
Created December 30, 2011 15:27
Show Gist options
  • Save phpspec/1540309 to your computer and use it in GitHub Desktop.
Save phpspec/1540309 to your computer and use it in GitHub Desktop.
Example of existing syntax
<?php
class StringCalculator extends \PHPSpec\Context
{
function before()
{
$this->calculator = $this->spec(new StringCalculator);
}
function itReturnsZeroWithNoArguments()
{
$this->calculator->add()->should->equal(0);
}
function itReturnsZeroWhenZeroIsPassed()
{
$this->calculator->add("0")->should->equal(0);
}
function itReturnsTheBareNumber()
{
$this->calculator->add("42")->should->equal(42);
}
function itReturnsTheSumOfSpaceSeparatedNumbers()
{
$this->calculator->add("42 7")->should->equal(49);
}
function itReturnsTheSumOfAnyWhiteSpaceSeparatedNumbers()
{
$this->pending()
}
function itAllowsYouToSpecifyAnySeparator()
{
$this->pending();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment