[rspec-users] Step matchers

Pat Maddox pergesu at gmail.com
Mon Oct 15 18:11:30 EDT 2007

On 10/15/07, James Hughes <hughes.james at gmail.com> wrote:
> On 10/15/07, Wincent Colaiuta <win at wincent.com> wrote:
> > El 15/10/2007, a las 14:21, "David Chelimsky" <dchelimsky at gmail.com>
> > escribió:
> >
> > > On 10/15/07, Wincent Colaiuta <win at wincent.com> wrote:
> > >>
> > >> - The customer/client (not necessarily with any programming
> > >> knowledge) writes the stories in a format which is (almost) plain
> > >> text.
> > >
> > > Why almost? Because there is required syntax? We're asking them to be
> > > able to write this:
> > >
> > > Story: employee accrues 1 day per month
> > >
> > >  As an employee
> > >  I want to accrue 1 day per month during my first year
> > >  So that I can replenish my self
> > >
> > >  Scenario: accrual after one month
> > >    Given an employee
> > >    When employee has worked 1 month
> > >    Then employee should accrue 1 day vacation time
> > >
> > >  Scenario: accrual after 2 months
> > >    Given an employee
> > >    When employee has worked 2 months
> > >    Then employee should accrue 1 days vacation time
> >
> > And as far as requirements go the leading whitespace could be treated
> > as totally optional (because you can rest assured that people will
> > get it wrong, use tabs instead of spaces, or spaces instead of tabs,
> > or mix them up etc).
> >
> > >> - The developer then writes custom "step matchers"; where do they go?
> > >
> > > TBD. Probably in a directory under stories named steps or
> > > step_matchers.
> >
> > My main concern here is that you're now having to keep two files in
> > sync to have the stories work properly. The great thing about the
> > Story Runner in its current form (and RSpec too) is that you can
> > start off by writing a skeleton using a natural-language-like Ruby
> > DSL, and then you flesh it out with code to fulfill its purpose. In
> > other words, turn on code folding and a non-programmer can read it
> > out loud and know what it means; turn off code folding and a
> > programmer can see what's happening inside. It's great because your
> > spec files are both readable by all and executable by the computer!
> >
> Just wanted to chime in and say, as a regular user of the folding
> features of the editor, this is what really resonated with me when
> Story Runner was first introduced. In fact, I recently did a short
> presentation to some coworkers and did exactly what is described here:
> put a story up with folding turned on to show the "story" without
> accompanying code, and then opened up various folds to show the
> implementation.

I don't want my customers to need a code editor to look at specs.  I
also don't want them to have to understand what :type => RailsStory,
%{this stuff}, and do...end are.

Ideally, I would show a customer some stories I wrote up, explaining
that they're organized that way "because it helps keep my thinking
organized."  Then I run a command and it says all the stories pass.
Then I take out some line, run the code again, and a message pops up
saying, "The page should show 'page name' but it didn't."  Then a
lightbulb goes off for my customer.

The whole point of RSpec, to me, is mapping the code as closely as
possible to what goes on in my brain.  Implementing specs in Ruby is
great because I'm a programmer, I think that way, and I want the
facilities of a powerful language.  Stories, on the other hand, are
customer-facing.  If we want to map stories as closely as possible to
how customers think, that means using plain text and no code.  This
hasn't really been possible with the available tools in the past, and
I think we're at a point where it finally is a reality.  That's what I
find so exciting about this.  If you need to use code to express
certain parts, you're better off just using a real language.  That's
where fitnesse falls apart in my mind.  The goals are noble, but you
can't do everything entirely in text/tables and you end up with leaky
abstractions.  But now, perhaps you *can* express everything entirely
in plain text, and that is immensely powerful.


More information about the rspec-users mailing list