[rspec-users] BDD / cucumber thought - chaining 'Then' steps with Which

Matt Wynne matt at mattwynne.net
Fri Sep 26 08:59:55 EDT 2008

On 26 Sep 2008, at 13:33, David Chelimsky wrote:

> On Fri, Sep 26, 2008 at 6:30 AM, Matt Wynne <matt at mattwynne.net>  
> wrote:
>> Going back to the debate about keeping state between steps, I  
>> found myself
>> with the mild urge to be able to write this today:
>> Given there is a user
>> And the user has 20 friends
>> Then I should see a thumbnail of each of the users's friends
>> Which should be a link to the user profile page for that friend
>> NB: An idiom in this which may be songkick-only but was inspired  
>> by what
>> we've read on this list, and worth explaining: "the user" as in  
>> "the user
>> has 20 friends", means User.first in rails. If there's more than  
>> one user
>> when this step runs, it will flunk, because the English no longer  
>> works.
>> So anyway, what I was thinking was that it would be nice to be  
>> able to refer
>> to the last thing I said I should be able to see, and decorate it  
>> with more
>> specification in a subsequent step or steps.
>> Obviously, I could roll these into one long Then step, but maybe  
>> this is
>> more elegant...
>> Just thinking out loud. I have no idea what the steps code would  
>> look like.
>> WDYT?
> One of the promises of using treetop is the ability to extend the
> grammar yourself to include keywords like Which.

Wow. OK I need to check that out.

> are uniquely named. See http://gist.github.com/13087.
> Other people have experiences, positive or negative, sharing state
> across steps with instance variables?

So far, my most remarkable experience is that we had some pretty in- 
depth debates in the office about whether it was a good or bad thing!  
It's certainly a hot topic.


In case you wondered: The opinions expressed in this email are my own  
and do not necessarily reflect the views of any former, current or  
future employers of mine.

More information about the rspec-users mailing list