Change factory_girl load path

144 views
Skip to first unread message

Rahul Sharma

unread,
Aug 18, 2012, 5:35:18 PM8/18/12
to factor...@googlegroups.com
Hi Guys,

I am working on a rails project that has cucumber tests built in. I want to define cucumber factories that are separate to spec/factories. Some cucumber factories will have the same name as the spec/factories. So As soon as I define factories with the same name, it give mea FactoryGirl::DuplicateDefinitionError.

Anyway, I can tell FactoryGirl to not load from the default path when running cucumber?

I tried FactoryGirl.definition_file_paths = %w(support/factories) but it still gives the same error? Any way to resolve this?

Joe Ferris

unread,
Aug 20, 2012, 9:53:39 AM8/20/12
to factor...@googlegroups.com
Hey,

The best solution I can think of for this situation is to use spec/support/factories.rb and features/support/factories.rb. That will prevent factory_girl from autoloading factories in either case, and will allow RSpec/Cucumber to load factories when appropriate.

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

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
For more options, visit this group at

Reply all
Reply to author
Forward
0 new messages