On Fri, Feb 17, 2012 at 6:31 AM, Julian Leviston <[email protected]>wrote:

> 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.
>

Could you show the Factory you are using now and how that exactly it fails
or what you
cannot do?

I presume the problem can be solved. I use a mix of FactoryGirl for
creating short lived objects
(mostly in memory, sometimes in the database) and some static data in the
database where I
find that more appropriate.

HTH,

Peter


-- 
*** Available for a new project ***

Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to