[rspec-users] Constraints / Global requirements

Stephen Eley sfeley at gmail.com
Wed Jan 7 21:22:26 EST 2009

On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor <stevemolitor at gmail.com> wrote:
>  Lots of features use the word "should" in their then clauses.
>  Take this example from the 'Feature Introduction' of the cucumber wiki:
> Scenario: Buy last coffee
>     Given there are 1 coffees left in the machine
>     And I have deposited 1$
>     When I press the coffee button
>     Then I should be served a coffee

Maybe I'm overly audacious, but I'd call that imprecise wording.  A
better clause would be "Then I am served a coffee."

(Actually, that feature has more than one thing wrong with it.  The
"depositing $1" part really ought to be a When, not a Given, since
it's an action integral to the scenario rather than a starting state.
Unfortunately, this often happens when people make up theoretical
examples instead of presenting real tests for real code.  I'll be this
feature was never actually part of designing a coffee machine...)

> Should this be an rspec example instead?  It certainly could be, but I don't
> think an rspec example would communicate as well with the customer as the
> feature would.  And that's the primary goal here (as Pat and Matt have
> reminded me!).

I agree.  This is a flawed feature, but it really ought to be a
feature: it describes a stimulus (an action) and a response.  But this
example doesn't have much in common with your original e-mail
validation example.  In that case, what's the action and what's the
response?  And is a feature clearer to the customer to explain e-mail
validation than a spec?

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list