[rspec-users] [cucumber] Using worlds for loading fixtures

Joseph Wilk joe at josephwilk.net
Fri Mar 13 06:11:42 EDT 2009


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.

3. 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 Wilk
http://blog.josephwilk.net



More information about the rspec-users mailing list