[rspec-users] Step matchers

David Chelimsky dchelimsky at gmail.com
Mon Oct 15 11:07:51 EDT 2007


On 10/15/07, Alvin Schur <a.schur at nucleus.com> wrote:
> Message: 7
> > Date: Sun, 14 Oct 2007 18:04:33 -0500
> > From: "David Chelimsky" <dchelimsky at gmail.com>
> > Subject: Re: [rspec-users] Step matchers
> > To: rspec-users <rspec-users at rubyforge.org>
> > Message-ID:
> >       <57c63afe0710141604m6a65d16an752c1df5a3d6bf3b at mail.gmail.com>
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > On 10/14/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> >
> >> On 10/14/07, Pat Maddox <pergesu at gmail.com> wrote:
> >>
> >>> I think we all know that the readability of steps isn't great right
> >>> now, and in fact there's a very recent thread that discusses just
> >>> that.  It was that recent thread that prompted me to explore this a
> >>> bit.
> >>>
> >>> The basic idea is that you define step matchers, which have a regex,
> >>> and then you match step names against that regex.  Kind of tough for
> >>> me to explain so I'll just link to some code :)
> >>>
> >>> spec: http://pastie.caboo.se/107116
> >>> impl: http://pastie.caboo.se/107117
> >>>
> >>> Instead of writing
> >>> Given "a user named __ who is __ years old", "Pat Maddox", 22
> >>>
> >>> it allows you to write
> >>> Given "a user named Pat Maddox who is 22 years old"
> >>>
> >>> I wrote it out as a separate matcher because it was just easiest to do
> >>> it that way while I explored this approach, no messing around with
> >>> RSpec internals to get it to really work.  However if we went this
> >>> route the structure would certainly be different.
> >>>
> >>> Hopefully you can get the idea from the example code.  Ideally what I
> >>> would like is to write step libraries that are external to the stories
> >>> themselves.  The stories would be much clearer because the
> >>> implementation would not be embedded, and the step names themselves
> >>> would make a lot more sense.
> >>>
> >>> wdyt?
> >>>
> >> LOL - I just suggested something like this in the other thread you
> >> cite. Though your idea strikes me as far more flexible and usable.
> >> Well done!!!!
> >>
> >
> > This just occurs to me. If we do away with the need for special
> > characters/positioning, blocks, etc, we should be able to do just
> > this, no?
> >
> > Given a savings account with 100 dollars
> > When the account owner asks for 101 dollars
> > Then the account owner should receive 0 dollars
> > Then the account should have 100 dollars
> >
> > Look mom - no quotes!
> >
> I like the ideas presented so far.
>
> What happens when a user makes a typo in a step?
>
> eg: a missing 'u' in account
>
> When the accont owner asks for 101 dollars
>
>
> How can we help the user to recognize the typo?

At first I would imagine you just get an UnknownStep error (or
similar). That would trigger a conversation w/ a developer who would
peruse the step matchers. Perhaps the next step would be a command to
print out all the step matcher expressions so it becomes easier to
find the expression (or perhaps that this When has no step defined for
it yet). Eventually we could make it smarter, but that would be a way
down the road.

>
> Alvin.
>
> > Cheers,
> > David
> >
> >
> >> Cheers,
> >> David
> >>
> >>
> >>> Pat
> >>> _______________________________________________
> >>> rspec-users mailing list
> >>> rspec-users at rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>>
> >>>
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> > End of rspec-users Digest, Vol 16, Issue 43
> > *******************************************
> >
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list