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
现在,在我尝试这一办法时,我收到了一份解释性警告,告诉我:
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?
增 编