I have a factory and a trait. I'd want to set attribute in factory and later modify this attribute using trait:
factory :photo_gallery do
photos { PhotosGenerator.generate_10_photos }
after(:build) do |photo_gallery|
# set value of some other attribute based on value of photos attribute
end
end
trait :non_broken do
photos { photos.reject(&:broken?) } # raises `stack level too deep (SystemStackError)`
end
As you see it raises SystemStackError
. How can I set value of photos
attribute in a trait based on value that was set for this attribute in factory?