Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Last active December 17, 2015 07:28
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 robyurkowski/5572738 to your computer and use it in GitHub Desktop.
Save robyurkowski/5572738 to your computer and use it in GitHub Desktop.
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "email#{n}@example.com" }
password "secret"
factory :admin do
after_build {|u| u.roles << :admin }
end
end
end
# And then use it like this...
admin_user = FactoryGirl.create(:admin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment