Class: NoBrainer::Matchers::Validations::ValidateUniquenessOfMatcher
Instance Method Summary
collapse
#failure_message_for_should, #failure_message_for_should_not, #on, #with_message
Constructor Details
Returns a new instance of ValidateUniquenessOfMatcher.
7
8
9
|
# File 'lib/matchers/validations/uniqueness_of.rb', line 7
def initialize(field)
super(field, :uniqueness)
end
|
Instance Method Details
#description ⇒ Object
25
26
27
28
29
|
# File 'lib/matchers/validations/uniqueness_of.rb', line 25
def description
options_desc = []
options_desc << " scoped to #{@scope.inspect}" if @scope
"#{super}#{options_desc.to_sentence}"
end
|
#matches?(actual) ⇒ Boolean
17
18
19
20
21
22
23
|
# File 'lib/matchers/validations/uniqueness_of.rb', line 17
def matches?(actual)
return false unless @result = super(actual)
check_scope if @scope
@result
end
|
#scoped_to(*scope) ⇒ Object
Also known as:
scoped_on
11
12
13
14
|
# File 'lib/matchers/validations/uniqueness_of.rb', line 11
def scoped_to(*scope)
@scope = [scope].flatten.map(&:to_sym)
self
end
|