[rspec-users] Help with regexp in matcher

James Byrne lists at ruby-forum.com
Tue Jan 13 10:41:47 EST 2009

Thanks for all the advise and corrections. I ended up with this:

When /\bsee a (?:log|sign)(?: ?)[io]n success message/ do
  # login | log in | logon | log on | signin ...
  Then "see the login ok message"

As to the issue of whether this is being too clever by half: Perhaps.

I have to consider though, that various people are going to be working 
on features relating to this project under a wide range of circumstances 
and that features will develop over a long period of time.  While it 
might appear attractive to simply insist that a session is always a 
login the fact is that language is not so precise;  login, logon, log 
in, log on, signin, signon, sign in and sign on are all common synonyms 
for the same action.  Internally, the action is just login.

Logins are a pervasive feature of this 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.  Admittedly, I also 
availed myself of this opportunity to gain additional knowledge 
regarding regexp and so this example is perhaps overwrought for the 
actual purpose at hand.

Finally, thank you Ben very much for the reference to 

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list