Reputation: 563
Class Person:
class Person < ActiveRecord::Base
validates_uniqueness_of :user_name, scope: :account_id
end
For the Person Class, I can test it using the validate_uniqueness_of testing method, something like:
it { is_expected.to validate_uniqueness_of(:user_name).scoped_to(:account_id)
Class Article:
class Article < ActiveRecord::Base
validates_uniqueness_of :title, conditions: -> { where.not(status: 'archived') }
end
However, I can't seem to be able to find the equivalent "shoulda-matcher" testing method with validate_uniqueness_of
for my Article class which contains conditions
in the documentation.
I have searched on google but I still can't seem to find a solution. Do I have to write a custom testing method for this?
Upvotes: 1
Views: 1103
Reputation: 2344
We've known about this for a little while now, but unfortunately we haven't addressed it yet. As tpbowden said, you'll have to test it manually. Sorry :(
Upvotes: 4