class Mongoid::Matchers::Validations::ValidateWithCustomValidatorMatcher
Public Class Methods
new(field)
click to toggle source
Calls superclass method
Mongoid::Matchers::Validations::HaveValidationMatcher::new
# File lib/matchers/validations/custom_validation_of.rb, line 5 def initialize(field) super(field, :custom) end
Public Instance Methods
description()
click to toggle source
# File lib/matchers/validations/custom_validation_of.rb, line 21 def description options_desc = [] options_desc << " with custom validator #{@custom_validator.name}" if @validator "validate field #{@field.inspect}" << options_desc.to_sentence end
matches?(actual)
click to toggle source
Calls superclass method
Mongoid::Matchers::Validations::HaveValidationMatcher#matches?
# File lib/matchers/validations/custom_validation_of.rb, line 14 def matches?(actual) return false unless (@result = super(actual)) check_custom_validator if @custom_validator @result end
with_validator(custom_validator)
click to toggle source
# File lib/matchers/validations/custom_validation_of.rb, line 9 def with_validator(custom_validator) @custom_validator = custom_validator self end
Private Instance Methods
check_custom_validator()
click to toggle source
# File lib/matchers/validations/custom_validation_of.rb, line 29 def check_custom_validator if @validator.is_a? @custom_validator @positive_result_message << " with custom validator of type #{@custom_validator.name}" else @negative_result_message << " with custom validator not of type #{@custom_validator.name}" @result = false end end