问题
Previously in Factory girl, we could define sequences like so:
# /spec/factories.rb
FactoryGirl.define do
# this is the sequence in question:
sequence(:random_token) { Digest::MD5.hexdigest(rand.to_s) }
factory :story do
sequence(:title) { |n| "My Cool Story##{n}" }
# Call the sequence here:
token { Factory.next(:random_token) }
description { "#{title} description"}
end
end
Now, when I try that approach - I get a deprecation warning telling me:
WARNING: FactoryGirl::Sequence#next is deprecated.
Use #run instead.
When I replace #next with #run, I get a no-method error. I can't find the new syntax in any of the docs... Can anyone point me in the right direction?
Thanks
回答1:
I think you should use Factory.create(...)
instead, e.g.
token { Factory.create(:random_token) }
来源:https://stackoverflow.com/questions/5497801/how-do-i-define-sequences-in-factorygirlrails