class NoBrainer::Matchers::Validations::ValidateUniquenessOfMatcher
Public Class Methods
new(field)
click to toggle source
Calls superclass method
NoBrainer::Matchers::Validations::HaveValidationMatcher::new
# File lib/matchers/validations/uniqueness_of.rb, line 7 def initialize(field) super(field, :uniqueness) end
Public Instance Methods
description()
click to toggle source
# 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)
click to toggle source
Calls superclass method
NoBrainer::Matchers::Validations::HaveValidationMatcher#matches?
# 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)
click to toggle source
# File lib/matchers/validations/uniqueness_of.rb, line 11 def scoped_to(*scope) @scope = [scope].flatten.map(&:to_sym) self end
Also aliased as: scoped_on
Private Instance Methods
check_scope()
click to toggle source
# File lib/matchers/validations/uniqueness_of.rb, line 33 def check_scope message = " scope to #{@validator.options[:scope]}" if @validator.options[:scope] if [@validator.options[:scope] || ''].flatten.map(&:to_sym) == @scope @positive_result_message += message else @negative_result_message += message end else @negative_result_message += ' without a scope' @result = false end end