[rspec-users] [Cucumber] Tables

Matt Wynne matt at mattwynne.net
Tue Apr 21 17:17:03 EDT 2009

On 21 Apr 2009, at 22:13, aslak hellesoy wrote:

> On Tue, Apr 21, 2009 at 10:20 PM, Joseph Wilk <joe at josephwilk.net>  
> wrote:
> On Tue, Apr 21, 2009 at 7:32 PM, Jonathan Linowes
> <jonathan at parkerhill.com> wrote:
> >
> > On Apr 21, 2009, at 1:57 PM, Joseph Wilk wrote:
> >
> >> What you really want is an examples table that is embedded in a  
> step
> >> (different from a step table, maybe by keyword?) that causes the  
> step to be
> >> run multiple times for each of the values. So rather than using  
> placeholders
> >> we embedded a Examples table in the step.
> >
> >
> > like this?
> Not quite, I was thinking of running the whole scenario for the
> examples step table rather than just the step.
> However I really like Ben's suggestion of a sub-table
> (http://gist.github.com/99255).
> I think it would be conceptually easier for a non-technical user to
> grasp than my first suggestion which makes it a big win for me.
> Thanks a lot for all the suggestions so far. I like Ben's subtable  
> too.
> In the example: "I should be presented a menu with <Meat Options>" I  
> assume the step definition would be:
> Then /I should be presented a menu with/ do |meat_hash|
>   # meat_hash has the following value the 2nd time (Jewish):
>   {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'Y'}
> end
> However, having the <Meat Options> as part of the step would be  
> inconsistent with how the regexp matching is currently working.
> Here is an alternative: http://gist.github.com/99376
> The idea is that we add a new kind of multiline argument in addition  
> to pystrings and tables: Hash. This is
> done using the familiar <> delimiters as a multiline argument.  
> What's inside it has no significance other than documentation.
> The keys of the hash would be the same as the Examples table header  
> *minus* the columns that are referred in other steps.
> In essence it achieves the same as Ben's, but relying on a  
> convention (removing referenced columns) rather than introducing
> a new, more complex table markup.

I like.

I also like that it's called a 'meat hash'. Sounds tasty :)

Matt Wynne

More information about the rspec-users mailing list