FactoryGirl.define do factory :person do email { Faker::Internet.email } first_name { Faker::Name.first_name } last_name { Faker::Name.last_name } middle_name { Faker::Name.first_name } suffix { rand(100) < 10 ? %w{md sr jr ii iii iv esq pd vd}.sample : "" } organization end factory :individual, :parent => :person, :class => "Individual" do type "Individual" subtype "Individual" trait :person_attributes do email { Faker::Internet.email } first_name { Faker::Name.first_name } last_name { Faker::Name.last_name } middle_name { Faker::Name.first_name } suffix { rand(100) < 10 ? %w{md sr jr ii iii iv esq pd vd}.sample : "" } birth_day "8" birth_month "3" birth_year "1985" organization end trait :birthday do birth_day "8" birth_month "3" birth_year "1985" end trait :address do after(:create) do |person| create(:address, person: person) end end trait :note do after(:create) do |person| create(:note, person: person, organization: person.organization) end end trait :get_action do after(:create) do |person| create(:get_action, person: person, organization: person.organization) end end end factory :business, :parent => :person, :class => "Company" do type "Company" subtype "Business" end factory :foundation, :parent => :business do subtype "Foundation" end factory :government, :parent => :business do subtype "Government" end factory :nonprofit, :parent => :business do subtype "Nonprofit" end factory :other, :parent => :business do subtype "Other" end factory :person_without_email, :parent => :person do email nil end factory :dummy, :parent => :person do dummy true end factory :person_with_tag, :class => Person do email { Faker::Internet.email } first_name { Faker::Name.first_name } last_name { Faker::Name.last_name } middle_name { Faker::Name.first_name } tag_list { Faker::Lorem.word } organization end end