[rspec-users] Step matchers
a.schur at nucleus.com
Mon Oct 15 11:02:09 EDT 2007
> 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>
> <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
>>> 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.
>> 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?
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
> End of rspec-users Digest, Vol 16, Issue 43
More information about the rspec-users