Reputation: 4907
I have this factory generated:
FactoryGirl.define do
sequence :account_login do |n|
"login-#{ n }"
end
factory :account do
sequence :email do |n|
"someone#{n}@gmail.com"
end
email_confirmation { |account| account.send :email }
url { Faker::Internet.url }
login { generate(:account_login) }
password { Faker::Internet.password }
password_confirmation { |account| account.send(:password) }
current_password { |account| account.send(:password) }
twitter_account 'openhub'
name { Faker::Name.name + rand(999_999).to_s }
about_raw { Faker::Lorem.characters(10) }
activated_at { Time.current }
activation_code nil
country_code 'us'
email_master true
email_kudos true
email_posts true
association :github_verification
end
end
What I really need to do is to create a second factory that creates a user with a nil github_verification attribute.
Something like this:
factory :account_with_no_verifications, parent: :account do
associaton github_verification = nil
end
Is there a way to do that?
Upvotes: 1
Views: 33
Reputation: 7779
Just use FactoryGirl::Strategy::Null
http://www.rubydoc.info/github/thoughtbot/factory_girl/FactoryGirl/Strategy/Null
factory :account_with_no_verifications, parent: :account do
association github_verification, strategy: :null
end
Upvotes: 1