On 9 Apr 2009, at 20:36, Zach Dennis wrote:
On Thu, Apr 9, 2009 at 3:30 PM, Zach Dennis <zach.den...@gmail.com>
wrote:
On Thu, Apr 9, 2009 at 2:56 PM, Matt Wynne <m...@mattwynne.net>
wrote:
On 9 Apr 2009, at 17:47, Zach Dennis wrote:
On Thu, Apr 9, 2009 at 9:29 AM, Williams, Wesley
<wesley.willi...@sabre.com> wrote:
Matt,
Hmm, I think this is one way to do it. I will need to get my
customer
to think differently about defining the requirements. They
really like
the tables.
Some times table just work best. I love writing scenarios with
natural
language, but I've hit many cases where the inputs and outputs are
best displayed as a table, and it's easier for the customer to
gr0k,
then to read a short novel.
This kind of re-use that you seem to need sounds like a potential
feature for Cucumber. A way to utilize an external file to house a
table of data. e.g.:
Background
Given I have the following set of flights:
| foo | bar | baz |
...
Would become
Background
Given I have the following set of flights:
FromFile: flights/scheduleA
And then you'd have the flights/scheduleA house:
| foo | bar | baz |
...
Cucumber could dump in the table data it found from the file, and
print it out when running the scenarios, and it allows some sets of
sample data be re-used easily, in an understandable manner.
WDYT?
This is a good idea - people do this with Fit (as opposed to
Fitnesse) and
go straight to a spreadsheet for the examples.
I don't see why it needs a new Cucumber feature though - you could
easily
(and more flexibly) write a custom step yourself to load in the
data from an
external file, right?
That's true, but why does everyone need to write their file loading
step/code? It seems like something where flexibility really doesn't
benefit anyone, unless you are doing something unique and special,
which I think is different than simply being able to store example
tables in an external file.
One more though, how would you process your example table from a file
within a step? Would you do a giant "eval" after reading the contents?
Or would you reach into the guts of Cucumber to programmatically build
the right thing? Is there another way? I've never done it, so just
asking how you would approach this by writing your own step,
Not sure - I've not needed to do it yet, which is why I would balk at
generalising it into the Cucumber framework - seems a bit premature :)
I guess I would replace this:
Given I have the following set of flights:
| foo | bar | baz |
With this:
Given I have the set of flights specified in "test_data/foo.xls"
Then in that step matcher I'd open the spreadsheet, loop through the
rows and just do the same as I would with the hashes I'd normally get
from Cucumber I suppose.
Obviously you couldn't do this for scenario outline tables without
extending Cucumber, but that's another issue entirely.
Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users