[rspec-users] Help with regexp in matcher

Stephen Eley sfeley at gmail.com
Tue Jan 13 13:18:13 EST 2009

On Tue, Jan 13, 2009 at 10:41 AM, James Byrne <lists at ruby-forum.com> wrote:
> Logins are a pervasive feature of this application

Which is exactly why you should standardize.  If you try to be
accommodating toward unclear communication, you're just going to
create confusion when people need to get things done.  Someone won't
remember whether the action is named "login" or "signin" or "sign_on"
and will waste time looking for the wrong thing -- or worse, write the
same function over again under a different name.  That's not the fault
of the feature, but it doesn't _help._  This step doesn't do as much
as it could to accurately document your application.

> and so, rather than
> waste effort on policing the feature syntax, I thought it best just to
> accommodate the likely variations from the start.

Well, first, if that was _really_ your goal you're not going nearly
far enough.  If a teammate isn't going to take the trouble to review
existing steps, he's probably more likely to screw up the "success
message" part than the "login" part.  How many variations on the
concept of "success message" do you think you can fit in a regex?
("acknowledgement" and "acceptance" both start with "ac," so I guess
you could start your conditional branching logic there...  Just
remember that the number of e's in "acknowledgment" can vary...)

Beyond that, though...  It's really not a problem.  Issues like this
tend to be self-correcting.  Most developers (well, most competent and
properly lazy ones) will read the existing features before writing
their own.  They'll know that if they saw a clause already that does
something they want, they should use it again.  And if they
misremember and type something else, they'll get a failure and think,
"Whathuh?  James got his features to work yesterday and HE needs to
log in!"  And *then* they'll think to look back at the step code, see
one called 'When "I see a success message"," and figure out what they
really ought to say.  In looking it up, they'll come to understand the
existing functionality better.

And they'd certainly be able to look it up in less time than it takes
to figure out all the regexes.  (Or me to be a smartass about them.

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list