On Tue, Apr 21, 2009 at 6:56 PM, David Chelimsky <dchelim...@gmail.com>wrote:

> On Tue, Apr 21, 2009 at 11:39 AM, aslak hellesoy
> <aslak.helle...@gmail.com> wrote:
> > Being the author of Cucumber, some of you might be surprised that I ask
> this
> > question:
> >
> > How should I go about to implement a Cucumber feature and step definition
> > with the following data?
> > http://gist.github.com/99220 (just look at the first file for now)
>
> You left out:
>
> | Vegetarian   |    N |    N |    N |
>
> >
> > Imagine I'm opening a restaurant where customers are asked for their
> > religion. Based on what they answer, they will be presented with a
> tailored
> > menu. (Apologies in advance if I'm ignorant about what different people
> it).
> >
> > In Cucumber, there are several ways to put this table in a feature. It
> can
> > be part of a table in a Scenario Outline's Examples section
> > (http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines), or it
> can
> > be sent to a Step as a multiline argument
> > (http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments
> ).
> >
> > In either case, I'm not happy about the feature and step definitions I
> end
> > up with. The Scenario Outline version has annoying duplication. I have to
> > duplicate each meat 3 times! This makes it hard to read and edit. The
> > multiline step argument version isn't much better. If a menu for a
> religion
> > is wrong I'll only get one error, the error won't tell me what's wrong
> > (unless I explicitly craft my error messages in the step definition) and
> max
> > one failure will show (there is only one scenario).
> >
> > There should be a better way to express this kind of tests. But I'm not
> sure
> > how. Is there a smarter way with the current Cucumber? If not, how would
> you
> > *like* to express this sort of problem?
>
> How about something like this:
>
> http://gist.github.com/99235
>

This is actually one of the best I've seen so far. However it doesn't scale
for multiple columns. (Imagine if you have 5 of them - they easily get mixed
up, or you make a spelling mistake).

I have also taken the meat+hamburge example and tweaked a little bit:
http://gist.github.com/99620
As you can see I'm a little sceptical of complex tables. Instead I have
invented the Range for feature writers. You specify a range of columns you
want for a column hash. (This could work along with my example where you
don't specify a range, just any token, and get the "rest").


> That doesn't require a new construct and I *think* it solves the
> problem (obviously I haven't run it).
>
> An alternative would be to add a new rule or construct in which the
> step definition can drive things a bit more. Something like
> http://gist.github.com/99244 where the fact that the step def accepts
> 3 block args would let it consume the next three columns in the table.
> Not sure how crazy that would be - just an idea.
>

That's an interesting idea, but would't this introduce a positional
dependency that could make it hard to detect mistakes? I'll have to think
more about it.

I love this discussion! More! More!

Aslak


> WDYT?
>
> >
> > Cheers,
> > Aslak
> >
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to