[cucumber] Using worlds for loading fixtures


#1

What is the right place to load fixtures specific to a given scenario? I
was thinking of using Worlds. Is it the right place for loading/deleting
fixtures? How do I specify which world scenario should run in?


#2

Fedor Fomenko wrote:

What is the right place to load fixtures specific to a given scenario? I
was thinking of using Worlds. Is it the right place for loading/deleting
fixtures? How do I specify which world scenario should run in?

There 3 options I can think of:

  1. Background Feature
    This allows you to specify specific set of steps which are only run for
    the scenarios in the relevant feature
    (http://wiki.github.com/aslakhellesoy/cucumber/background). I would
    recommend this approach if you are using the latest cucumber version
    from github.

2, In the scenario
Are you hiding state setup which would be better placed in the plain
text scenario? You don’t have to get too granular with the data setup, a
high level “Given the system is setup…” style could be used to avoid
noise that detracts from the scenario value.

  1. Before
    If you do this in a Before you can gain access to the scenario name
    (http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/44). You
    could switch this to run the relevant fixture if you wish. (This is a
    bit smelly)

HTH


Joseph W.
http://blog.josephwilk.net


#3

On Fri, Mar 13, 2009 at 11:37 AM, Pat M. removed_email_address@domain.invalid
wrote:

  1. Background Feature
    2, In the scenario
    If you do this in a Before you can gain access to the scenario name (
    http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/44). You
    could switch this to run the relevant fixture if you wish. (This is a bit
    smelly)

You could clean it up: http://gist.github.com/78518 but it’s still
horrible :stuck_out_tongue:

How about this:
http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/229-use-hooks-with-tags

Aslak


#4

On Mar 13, 2009, at 3:11 AM, Joseph W. wrote:

This allows you to specify specific set of steps which are only run
for the scenarios in the relevant feature (http://wiki.github.com/aslakhellesoy/cucumber/background
). I would recommend this approach if you are using the latest
cucumber version from github.

Makes sense if it applies to every scenario within a feature.

2, In the scenario
Are you hiding state setup which would be better placed in the plain
text scenario? You don’t have to get too granular with the data
setup, a high level “Given the system is setup…” style could be
used to avoid noise that detracts from the scenario value.

What I do 99% of the time.

  1. Before
    If you do this in a Before you can gain access to the scenario name (http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/44
    ). You could switch this to run the relevant fixture if you wish.
    (This is a bit smelly)

You could clean it up: http://gist.github.com/78518 but it’s still
horrible :stuck_out_tongue:

Pat