[rspec-users] Step matchers

Pat Maddox pergesu at gmail.com
Sun Oct 14 16:12:30 EDT 2007

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.



More information about the rspec-users mailing list