Sharing factories via a gem?

191 views
Skip to first unread message

Justin Wiley

unread,
May 16, 2012, 10:13:44 AM5/16/12
to factor...@googlegroups.com
I have a set of models that are shared between Rails applications, and currently live in a gem.  I would like to share the factories that are associated with them as well.

Whats the best way to do this?  Don't necessarily want to have to write a generator and dump them out, would prefer to include them somehow.

Any ideas?  Thanks!
Justin

Joe Ferris

unread,
May 16, 2012, 11:47:41 AM5/16/12
to factor...@googlegroups.com
Hey Justin,

I agree that having a generator copy them isn't ideal, especially since you can now modify existing factories.

I'd put them in lib/your_library/factories.rb, so users can just do `require your_library/factories` in their own factory file.

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

Justin Wiley

unread,
May 16, 2012, 12:49:08 PM5/16/12
to factor...@googlegroups.com
Ahhh, makes total sense.  Thanks Joe!
Reply all
Reply to author
Forward
0 new messages