【发布时间】:2016-01-26 08:51:33
【问题描述】:
我刚刚升级了我的 Rails 项目以使用 Shoulda Matchers 3.0
但是,验证 title 属性唯一性的模型测试现在失败了:
app/models/product.rb
it { is_expected.to validate_uniqueness_of(:title) }
spec/models/product_spec.rb
it { is_expected.to validate_uniqueness_of(:title) }
测试失败的错误信息是:
Product should validate that :title is case-sensitively unique
Failure/Error: it { is_expected.to validate_uniqueness_of(:title) }
Product did not properly validate that :title is case-sensitively
unique.
The record you provided could not be created, as it failed with the
following validation errors:
* title: ["can't be blank"]
* description: ["can't be blank"]
# ./spec/models/product_spec.rb:6:in `block (2 levels) in <top (required)>'
有人遇到过这个问题吗?
感谢您的帮助,
安东尼
【问题讨论】:
标签: ruby-on-rails shoulda