module Shoulda::Matchers::ActiveModel
def validate_uniqueness_of(attr)
it { should validate_uniqueness_of(:keyword).case_insensitive }
scoped_to(:first_name, :last_name) }
it { should validate_uniqueness_of(:email).
it { should validate_uniqueness_of(:email).scoped_to(:name) }
it { should validate_uniqueness_of(:keyword).with_message(/dup/) }
it { should validate_uniqueness_of(:keyword) }
Examples:
check case. Off by default. Ignored by non-text attributes.
* case_insensitive - ensures that the validation does not
* scoped_to - field(s) to scope the uniqueness to.
Defaults to the translation for :taken.
errors.on(:attribute). Regexp or String.
* with_message - value the test expects to find in
Options:
it { should validate_uniqueness_of(:email) }
Example:
`validate_uniqueness_of`.
constraints. In that case, you must create a record before calling
around validations, so it will probably fail if there are `NOT NULL`
exists in the database. It simply uses `validate: false` to get
It uses the first existing record or creates a new one if no record
Ensures that the model is invalid if the given attribute is not unique.
:nodoc:
def validate_uniqueness_of(attr) ValidateUniquenessOfMatcher.new(attr) end