【发布时间】:2019-02-28 11:05:10
【问题描述】:
我最近升级到rails 5,同时升级了gem shoulda-matchers。
我有一个带有email 属性的User 模型
电子邮件应该是唯一的,并且这种唯一性不区分大小写
class User < ApplicationRecord
validates :email, uniqueness: { case_sensitive: false }
end
我正在使用 rspec 进行测试
RSpec.describe User, type: :model do
subject { build(:user) }
[...]
it { is_expected.to validate_uniqueness_of(:email).ignoring_case_sensitivity }
end
但它会抛出这个错误
Expected User to validate that :email is unique, but this could not be proved.
Expected the validation not to be scoped to anything, but it was scoped to :provider instead.
我正在使用 devise 以防万一。
有点迷路了,特别是因为它曾经运行良好
非常感谢
【问题讨论】:
标签: ruby-on-rails rspec