Skip to content

Instantly share code, notes, and snippets.

@kylefox
Created May 20, 2009 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylefox/115124 to your computer and use it in GitHub Desktop.
Save kylefox/115124 to your computer and use it in GitHub Desktop.
# It would be awesome if factory_girl let you specify multiple parent factories.
Factory.define :user do |f|
# normal factory definition ...
end
Factory.define :superuser, :parent => :user do |f|
f.is_superuser true
end
Factory.define :active_user, :parent => :user do |f|
f.is_active true
end
# Hooray, no duplicate factory definitions!
Factory.define :active_superuser, :parents => [:active_user, :superuser] do |f|
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment