Table of Contents
The terminology used throughout Behaviour-Driven Development is focused entirely on the concept of describing behaviour. This alleviates any misunderstanding from attempting to describe the process of Test-Driven Development in terms of tests - a counterintuitive notion for many programmers.
The terms Spec and Example are almost used interchangeably. While a Spec refers to a
single behavioural requirement, often captured as a simple sentence of the
form "it should do something", an Example refers to the the entire method
within PHPSpec which demonstrates this Spec in code. If you take the
example below, the spec is the line of code commencing with
$this->spec() and the example is the entire
public method which shows how this spec is achievable
Example 5.1. A Spec in a PHPSpec Example Method
public function itShouldHaveScoreOfZero()
{
$bowling = new Bowling;
$bowling->hit(0);
$this->spec($bowling->score)->should->be(0);
}
A more difficult concept is that of a Context. In brief a Context is the set of conditions prevailing at the time we are specifying behaviour. Above, our Bowling example assumes we've just started a new game. This is the Context all our Specs in the same class would share. Later we might want a game which is finished, or partially played. Each different Context helps you explore how behaviour changes under different conditions.