小编Aru*_*run的帖子

如何解决factory_girl错误的参数个数错误

#rspec test code
@room = FactoryGirl.build(:room)

#factory definition
factory :room do
  length {10}
  width {20}
end

#code implementation
class Room
  attr_accessor :length, :width

  def initialize(length,width)
     @length = length
     @width = width 
  end

end
Run Code Online (Sandbox Code Playgroud)

尝试构建@room时,运行rspec会导致此错误

ArgumentError:参数数量错误(0表示2)

ruby factory-bot

10
推荐指数
2
解决办法
5848
查看次数

标签 统计

factory-bot ×1

ruby ×1