[rspec-users] Help with regexp in matcher

Matt Wynne matt at mattwynne.net
Wed Jan 14 03:37:51 EST 2009

On 13 Jan 2009, at 20:10, James Byrne wrote:

> Stephen Eley wrote:
>> 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.
> I appreciate the advice and accept the wisdom that it contains.  I  
> have
> no intention of handling with a regexp every situation where there  
> might
> be more than one English expression available to express a concept.   
> Nor
> do I intend to otherwise permit multiplicities of expression to exist.
> However, on the matter of log in versus log on and its common
> variations, I think I will stick with my initial instinct.   
> Initially I
> provided the different variants of login matchers along the lines  
> shown
> below:
> When /see a login success message/ do
>  have_selector("#login_current")
> end
> When /see a log in success message/ do
>  Then "see a login success message"
> end
> When /see a sign on success message/ do
> ...
> The revised regexp version simply puts all of these together in one
> place for me.  As for forcing people to remember that it is login and
> not logon;  well this project does not exist in a vacuum.  The people
> involved deal with at least three different operating systems every  
> day,
> each one of which has its own dialect with respect to what constitutes
> an authenticated user.  I will accept a little flexibility of  
> expression
> here in the service of user comfort.
> In any case the term login, in the context of a web application
> environment, seems a bit of a misnomer from the outset.  I cannot get
> too worked up over the idea of unclear communication when one is  
> dealing
> with as muddy a concept as that represented by login.  Really, what I
> should be saying is:
>  Given user "myuser" has a current authenticated session
>    And I see the session authenticated message
>  When I terminate my current session
>  Then the current session is destroyed
>    And I should see the user authentication request message
> However, current authenticated session tends to be a little unwieldy  
> in
> casual speech.

I actually rather like the unambiguous, and jargon-free 'current  
authenticated session' phraseology, but I'm not one of your users, so  
that doesn't really matter!

I have one more suggestion. From all these different ways of saying  
the same thing, pick a winner, then write a regexp step that catches  
all the possible alternative ways of expressing it you can think of,  
and raises an error saying "did you mean 'current authenticated  
session'" (or whatever).

That will meet both your original goal of making the features  
approachable for your users who are awash with different terminology  
from different systems, and the one that we're pushing you towards of  
trying to keep your domain vocabulary as simple as possible.

Matt Wynne

More information about the rspec-users mailing list