Rspec / Paperclip:即使使用以下文档,验证也会失败

时间:2013-11-14 17:05:46

标签: 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.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

不确定为什么会失败。非常感谢任何帮助!

0 个答案:

没有答案