Ruby on rails Rspec/回形针:即使有以下文档,验证也会失败
以下是我的验证:Ruby on rails Rspec/回形针:即使有以下文档,验证也会失败,ruby-on-rails,rspec,paperclip,shoulda,paperclip-validation,Ruby On Rails,Rspec,Paperclip,Shoulda,Paperclip Validation,以下是我的验证: describe User it { should validate_attachment_size(:avatar).less_than(20.megabytes) } end 以下是我的用户模型: class User < ActiveRecord::Base validates_attachment :avatar, :content_type => { :content_type => /image/ }, size: { in: 0..20
describe User
it { should validate_attachment_size(:avatar).less_than(20.megabytes) }
end
以下是我的用户模型:
class User < ActiveRecord::Base
validates_attachment :avatar, :content_type => { :content_type => /image/ }, size: { in: 0..20.megabytes }, allow_blank: true
end
我不知道为什么会失败。非常感谢您的帮助 可能是这样的:
Failure/Error: it { should validate_attachment_size(:avatar).less_than(20.megabytes) }
Attachment avatar must be between and 20971520 bytes