I'm using the factory_girl plugin in my rails application. For each model, I have a corresponding ruby file containing the factory data e.g.
Factory.define :valid_thing, :class => Thing do |t|
t.name 'Some valid thing'
# t.user ???
end
I have lots of different types of users (already defined in the user factory). If I try the following though:
Factory.define :valid_thing, :class => Thing do |t|
t.name 'Some valid thing'
t.user Factory(:valid_user) # Fails
end
I get the following error:
# No such factory: valid_user (ArgumentError)
The :valid_user is actually valid though - I can use it in my tests - just not in my factories. Is there any way I can use a factory defined in another file in here?
Factory(:valid_user)
syntax has been deprecated; useFactoryGirl.create(:valid_user)
instead. – Householder