它我factorygirl代碼運行第二次當數避免factorygirl repeate黃瓜
FactoryGirl.define do
factory :account do
sequence :name do |n|
"Test Account#{n}"
end
end
end
這是我跑factorygirl碼方法
def create_accounts n=2
n.times do
FactoryGirl.create(:account, subscription_ids: @sub.id.to_s)
end
end
我的問題是,第一次我FactoryGirl輸出Test Account1, Test Account2
,當我執行第二次,它創建輸出爲Test Account3, Test Account4
。但是我多次運行時需要Test Account1, Test Account2
。我該如何做到這一點。
感謝您的建議
我已經在我的項目中使用了。非常感謝。如果我對database_cleaner有任何疑問,我會問你。 :) – Selvamani