rspec用户规范失败

时间:2019-05-12 15:18:06

标签: ruby-on-rails factory-bot

我在使用ruby 2.5.5版本的factorybot 规范失败,并出现以下错误

 Failure/Error: @user = FactoryBot.create(:user)
      NoMethodError:
        undefined method `password=' for #<User:0x000055dcec0bc628>
      # /bundle/gems/carrierwave-crop-0.1.2/lib/carrierwave/crop/model_additions.rb:42:in `method_missing'

//工厂漫游器代码

 FactoryBot.define do
  factory :user, aliases: [:author] do
    fullname { 'user1' }
    email { "user#{rand(999)}@gmail.com" }
    password { 'passwordis12345' }
  end
end

1 个答案:

答案 0 :(得分:0)

这是因为缺少attr_accessor