[rspec-users] Cucumber - Adding a step definition

Josh Chisholm joshuachisholm at gmail.com
Sat Mar 14 20:30:59 EDT 2009


> That sounds like a great way to avoid the instance variable.

Why is a named record preferable to an instance variable? It seems
like the coupling between steps is the same, but the coupled state is
stored differently. Maybe that's the point - stored differently.

I've been tempted to start scenario lines with "With" as well, to get
away from the combinatorial explosion of setup steps for complex
entities (think decorator pattern). I've used tables too, but mine
looked more like this:

Given a policy with:
  | PCF practice state | secondary risk |
  | yes                         | yes                   |

Is that nasty? It means we can use one step to set all possible
boolean attributes of a policy, but it doesn't read so well.

"With ..." would mean steps that were coupled to the "last mentioned
thing". That seems like a different kind of coupling - there is only
one piece of state involved (the last thing) rather than a map of
named things. But it's less explicit and implies that the "last thing"
needs to be updated by each step that mentions things.

Matt, going back to Mark's example, it sounds like you lean towards
the latter (i.e. repeat 'Reach from the Stars for 'Halo 3' throughout
the scenario). Is that correct?

Josh



On Sat, Mar 14, 2009 at 10:58 PM, Matt Wynne <matt at mattwynne.net> wrote:
>
> On 14 Mar 2009, at 22:01, Tim Hart wrote:
>
>> On Mar 14, 2009, at 3:38 PM, "Andrew Premdas"
>> <apremdas at gmail.com<mailto:apremdas at gmail.com>> wrote:
>>
>> Is the syntax you're using a misreading of the wiki advice on
>> Feature-Coupled Steps.
>>
>> Why not have
>>
>> "GIven a policy with a PCF practice state and seconday risk"
>>
>> Because the work we are currently doing is going to involve several
>> hundred different variations of over a hundred different attributes of a
>> policy. I need to make sure that I'm able to reuse as many statements
>> describing that policy as I possibly can.
>
> Have you thought about using Scenario Outlines to express these several
> hundred variations in a tabular format?
>
> That would enable you something like:
>
> Given a policy with <policy features>
> When blah
> Then <outcome>
>
> Examples:
> | policy features                        | outcome |
> | a PCF practice state and seconday risk | foo     |
>
> Just a thought.
>
>
>
> Matt Wynne
> http://blog.mattwynne.net
> http://www.songkick.com
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list