Class: Mongoid::Matchers::Validations::ValidateWithCustomValidatorMatcher
Instance Method Summary
collapse
#with_message
#check_on, #failure_message_for_should, #failure_message_for_should_not, #on
Constructor Details
Returns a new instance of ValidateWithCustomValidatorMatcher.
6
7
8
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 6
def initialize(field)
super(field, :custom)
end
|
Instance Method Details
#description ⇒ Object
23
24
25
26
27
28
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 23
def description
options_desc = []
options_desc << " with custom validator #{@custom_validator.name}" if @validator
options_desc << " with message '#{@expected_message}'" if @expected_message
"validate field #{@field.inspect}" << options_desc.to_sentence
end
|
#matches?(actual) ⇒ Boolean
15
16
17
18
19
20
21
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 15
def matches?(actual)
return false unless (@result = super(actual))
check_custom_validator if @custom_validator
check_expected_message if @expected_message
@result
end
|
#with_validator(custom_validator) ⇒ Object
10
11
12
13
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 10
def with_validator(custom_validator)
@custom_validator = custom_validator
self
end
|