[factory_girl] `rake spec` spins off 20-25 ruby processes bringing my computer almost to a halt

0 views
Skip to first unread message

Matt W.

unread,
May 7, 2010, 12:16:53 PM5/7/10
to factory_girl
I recently converted my project to use Factory Girl (about 60 models).
Now when I run my specs (seems to be only the initial run) about 20-25
ruby processes are spawned bringing my computer to a near halt. I
don't have anything too fancy in my factory definitions, a few
associations, and some sequences.

Originally in my specs I had something like Object.create!
(@valid_attributes), which I replaced with Factory(:object).

Prior to the conversion the specs ran quickly and I had no issues in
that regard.

So my question is: What could cause this behavior?

Any help will be greatly appreciated!

Thanks,
Matt

--
Individuals over processes. Interactions over tools. Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
http://thoughtbot.com/services/training

You received this message because you are subscribed to the "factory_girl" mailing list.
To post to this group, send email to factor...@googlegroups.com
To unsubscribe from this group, send email to
factory_girl...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/factory_girl?hl=en

Joe Ferris

unread,
May 7, 2010, 12:20:58 PM5/7/10
to factory_girl
factory_girl doesn't do anything to start separate processes, so it
seems like your models must be doing this when factory_girl saves
them. Are you using any kind of forking, background processing, or
anything else?

-Joe

Matt W.

unread,
May 7, 2010, 12:32:19 PM5/7/10
to factory_girl
There is a lot going on in this application…I am not the sole
maintainer and I didn't start it so there very well could be some
other things going on. I related the issue to FG simply because I
didn't have any problems prior to switching. I'll mess around with it
some more to see if I can pinpoint the issue. Thanks.

Matt W.

unread,
May 7, 2010, 1:08:57 PM5/7/10
to factory_girl
So, I'm thinking the issue is that prior to my Factory implementation,
many of the objects in the specs were being created without any
attributes. Because of the nature of some of these objects the
introduction of attributes is causing the spin offs. On that note…how
can I create a factory without any attributes? For example, if I have
a factory defined with all of the attributes (which will be useful for
many tests), but I want to create one without any attributes in
another spec, what's the best way to go about that?

Keenan Brock

unread,
May 7, 2010, 8:01:42 PM5/7/10
to factor...@googlegroups.com
Hi,

If you have a factory that creates an account:

Factory :account do
name { 'john' }
end

And you want another, just create one with a different name

Factory :empty_account, :class => Account do
end

in your test Factory(:empty_account)

You may also want to check out :parent, which includes all the parent test

--Keenan
Reply all
Reply to author
Forward
0 new messages