FactoryGirl中build_list的错误参数?

时间:2013-12-23 17:11:38

标签: ruby factory-bot

我没有使用Rails,而且我使用了以下工厂定义:

FactoryGirl.define do
  factory :program, class: TMSAPI::Model::Program do
    ...
    ratings             build_list(:rating, 3)
    ...
  end

  factory :rating, class: TMSAPI::Model::Rating do
    sequence(:body) { |n| "Rating Body #{n}" }
    sequence(:code) { |n| "Rating #{n}" }
  end
end

我收到以下错误:

c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/definition_proxy.rb:42:in `add_attribute': wrong number of arguments (3 for 1..2)
(ArgumentError)

代表ratings build_list(:rating, 3)行。

0 个答案:

没有答案