Skip to content

Instantly share code, notes, and snippets.

@tsabat
Last active December 28, 2015 01:39
Show Gist options
  • Save tsabat/7421758 to your computer and use it in GitHub Desktop.
Save tsabat/7421758 to your computer and use it in GitHub Desktop.

i've been fighting with FactoryGirl to create unique user IDs, emails, etc. on the User object and other factories.

The pattern I've followed for my objects is shown in this user factory

Notice the sequences for UNs, emails:

sequence(:email) {|x| "user_#{x}@codepen.io"}
sequence(:username) {|x| "un_#{x}"}
sequence(:github_id) {|x| x}
sequence(:github_username) {|x| x}

Also, I take care of the DB's indexing with this stuff in the spec_helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment