Hi All,
I’m hoping someone can help me out here.
I’m building a suite of tests for my (reasonably large) Rails app. I’m
using Rails 3.2 and I was using FactoryGirl, but I found that it
wasn’t able to build me the object graphs that I needed.
(Basically it doesn’t have a feature to re-use existing objects that are
created in the database in previous steps).
I’ve got a Model that references three other models, two of which
reference one other Model each. I want to simply call FactoryGirl.create
on the first model, and have it intelligently build the related
objects… the only issue is some of those objects should not be
re-created.
Essentially what I want is sets of remembered named objects that can be
referred to each other in a factory, but FactoryGirl nor Machinist seem
to do this at all. Machinist comes closest to what I want to do in that
it lets you override the attributes (and associations), yet it seems
borked in that Machinist 2’s make! method doesn’t seem to create the
related objects in for Rails 3.2.
Can anyone help out here? I’m trying to use the path of least resistance
to doing BDD (or at least putting it on after the fact) and I seem to be
getting stuck at the start of my object graph in order to do some of the
set up for my steps / tests.
Julian