Skip to content

Instantly share code, notes, and snippets.

Last active Feb 4, 2016
What would you like to do?
Automaton girl - leveraging factory girl for QA data

Set your vars

email = ""
user = User.find_by(email: email)
account = user.account
team =

def stub_with_random_traits(model, params={})
  FactoryGirl.create(model, *random_traits_for(model), params)

def random_traits_for(model)
  traits = FactoryGirl.factories[model]{|t| }
  number_of_traits = (rand*traits.length).floor{ traits[(rand*traits.length).floor] }.uniq

Fake some data

Cause making data is so boring and forever taking.


cadence = FactoryGirl.create(:cadence, :with_email_step, :with_phone_step, account: account)
5000.times { stub_with_random_traits(:person, account: account, cadence: cadence) rescue nil; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment