Skip to content

Instantly share code, notes, and snippets.

@kulte
Last active December 22, 2015 22:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kulte/6540998 to your computer and use it in GitHub Desktop.
factory :user do
email "bob.bobsen@gmail.com"
password "secret"
trait :with_comments do
after(:create) do |user, evaluator|
# FactoryGirl.create_list(factory, number_of_items, factory_attrs)
FactoryGirl.create_list(:comment, 1, user: user)
end
end
end
factory :comment do
text "This is a comment."
end
class User < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment