Last active
December 16, 2015 00:09
-
-
Save tagrudev/5345691 to your computer and use it in GitHub Desktop.
Singleton for a factory inside another's factory traits = No ideas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :user do | |
first_name 'John Doe' | |
last_name 'Doe' | |
trait :yolo do | |
first_name 'Spinder' | |
last_name 'Man' | |
end | |
factory :spinder, traits: [:yolo] | |
end | |
factory :message do | |
# Here I want :spinder and :user to be the same it the both traits | |
# YOLO | |
trait :from_spinder do | |
association :from, factory: :spinder | |
association :to, factory: :user | |
end | |
trait :from_john do | |
association :from, factory: :user | |
association :to, factory: :spinder | |
end | |
factory :message_from_spinder, traits: [:from_spinder] | |
factory :message_from_john, traits: [:from_john] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment