[rspec-users] Dealing with dependent data
chris at cobaltedge.com
Wed Jun 25 14:37:04 EDT 2008
If there's already been a thread on this, let me know (and if you can,
point me to it)...
In building my stories, I often need to setup a bunch of data where
you have multiple levels of models that depend on each other. For
example, I'd have models like Doctor, Organization, and Location. To
run various scenarios that view doctors, say by organization, or by
tags, or whatever, I need to setup fixture-like data for locations,
then organizations (which belong to a location), then docs which
belong to an organization. I am sure others have this in their apps,
and I'm wondering how you organize you Given's/steps across these
Right now, for example, I have doctor_steps, organization_steps, and
location_steps, which have their respective Givens in them. But,
what's been bugging me is that when one Given depends on another, the
only place this is really hinted at is in the plain text story file,
where I might have:
Scenario: view doctors
Given: existing locations
And: existing organizations
And: existing doctors
My steps that depend on other data always check for that existance.
e.g. in Organizations given, I'd do a "Location.count.should > 1" or
more specific depending on my needs, etc.
So, what are folks doing in this regard, any tips, recommendations,
suggestions, etc.? Is there some way to indicate dependencies like
this that I simply don't know about?
Cobalt Edge LLC
More information about the rspec-users