I have the following factory:
FactoryGirl.define do
factory :foo do
sequence(:name) { |n| "Foo #{n}" }
trait :y do
sequence(:name) { |n| "Fooy #{n}" }
end
end
end
If I run
create :foo
create :foo
create :foo, :y
I get Foo 1, Foo 2, Fooy 1
. But I want Foo1, Foo2, Fooy 3
. How can I achieve this?
After a couple of hints from smile2day's answer and this answer, I came to the following solution: