[rspec-devel] Stories vs. examples

Dan North tastapod at gmail.com
Wed Nov 7 18:52:48 EST 2007


The thing to bear in mind is that there are two different domains going on
for the user at the acceptance testing (scenario) level. There is the domain
of the business problem (transfer funds, authenticate yourself) and the
domain of the UI technology (navigate, click, type). The problems start when
you mix the two domain vocabularies.

The scenarios should be purely in business terms, so that you should be able
to replace a web app with a console app or a rich client or some people
running around with pieces of paper, and the scenario still makes sense. If
you have to change the wording in the scenario then it means you've confused
your levels of abstraction - your implementation UI vocabulary has leaked
into your scenario descriptions. This is usually a Bad Thing. That's why
your second example reads so much more naturally - it's how a business
stakeholder would describe the scenario independent of the technology.

In your step implementations (the "body" of each step) you would expect to
see code driving the implementing technology, say a browser. WebDriver (
http://code.google.com/p/webdriver/wiki/GettingStarted) or the Selenium
runner (http://tinyurl.com/ytls64 - sorry it's using Test::Unit) are good
examples of this.

Cheers,
Dan

On 11/7/07, Jake Howerton <jake.howerton at gmail.com> wrote:
>
> The question is ... where do we want to abstract.  If we abstract in
> the stories you might come up with the bottom example.  Although I
> think the top could be written alot more succintly than its current
> form.  If we abstract in the steps, we might have more verbose
> stories, but the steps can be much more reusable and less actual code
> would get written.
>
> Honestly most of my existing stories ( Not actually written by me)
> map much better to the detailed implementation than the abstract.
> Stories that get written by non programmers are going to have data in
> them.   "When I click on the Widgets Inc logo it blows up!" etc.
>
> Jake
>
> > Given an empty checking and savings account
> > And visiting the Money Transfer page
> > And typing transfer amount $20
> > And selecting from account "Checking"
> > And selecting to account "Savings"
> > When clicking "Transfer"
> > Then user should see error message "Insufficient funds"
> > And checking account should have balance $0
> > And savings accounts should have balance $0
> >
> > What about:
> >
> > Given an empty checking and savings account
> > When user tries transferring $20 from checking to savings
> > Then user should see message "Insufficient funds"
> > And checking account should have balance $0
> > And savings accounts should have balance $0
> >
> > The clicks, typing and selects still happen behind the scenes, but
> > aren't really important at the story level.
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20071107/1761f482/attachment.html 


More information about the rspec-devel mailing list