[rspec-users] [Cucumber] Tables
Kero van Gelder
kero at chello.nl
Wed Apr 22 13:14:37 EDT 2009
> > Without adding a new feature to Cucumber, I'd probably do
> > Scenario Outline: Religious menus
> > Given the customer is a "<Religion>"
> > When they ask for the menu
> > Then they should be presented with "<Meats>"
> > Examples:
> > | Religion | Meats |
> > | Christian | Pork, Lamb, Veal |
> > | Jewish | Lamb, Veal |
> > | Muslim | Lamb, Veal |
> > | Hindu | Lamb |
> This certainly would work, but what if we're not dealing with booleans
> (Lamb/No Lamb), but numbers?
> |34,76,89| doesn't read so well...
Actually, I did just that, together with a colleague.
(I removed info about what the algorithm actually computes, but
the +/- indicates a threshold for that algorithm is/is not crossed;
there are four algorithms not two; sorry about all that editing)
Scenario Outline: measuring a series of daily weights
Given patient Lara
When she measures her weight as <weights> kg
Then ROT algorithm result should be <ROT>
And MACD algorithm result should be <MACD>
| weights | ROT | MACD | ...
| 71 72.5 72 73.3 73.6 | + | - |
| 71 72 73 74 75 | - | + |
I find this readable enough (it is much more readable than the long
series of scenarios we had before).
The numbers are a sequence as input for the algorithm.
The sequences are concrete examples to show the differences between the
outcomes of the four algorithms.
What strikes me in your meat examples, is that there is a mapping
from religion to types of meat that can be served (or dishes, in the end).
You can test that the mapping works, why are you trying to be
exhaustive in your examples?
More information about the rspec-users