On Thu, Jun 26, 2008 at 4:37 AM, Christopher Bailey <[EMAIL PROTECTED]> wrote: > If there's already been a thread on this, let me know (and if you can, > point me to it)...
I asked something similar about a week or so ago, you can see it here: http://www.ruby-forum.com/topic/156392 It is on 'reusing story specs' But I have done some more work since then... > 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 > Scenario: view doctors > Given: existing locations > And: existing organizations > And: existing doctors You can use plain text stories and use multiple steps_for to get a similar effect. But in this case, on that set of stories, it would make sense to reduce that Given block down to: # viewing doctors story file... Scenario: view doctors Given: existing doctors in organizations that have a location When... And then I would use some helpers or fixture loading to handle your data loading... # spec helper file... def build_valid_doctor(params) location = Location.create(:blah...) org = Organization.create(:location => location) Doctor.create({:organization => org}.merge(params)) end # steps file.... steps_for :viewing_doctors do Given "existing doctors in organizations that have a location" build_valid_doctor(:surname => 'Hyde') build_valid_doctor(:surname => 'Jeckle') end end Of course you can make those factory methods do all sorts of things... Hope that helps Mikel -- http://lindsaar.net/ Rails, RSpec, Puppet andLife blog.... _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users