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