Class: Shoulda::Matchers::ActiveModel::ValidationMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveModel::ValidationMatcher
show all
- Includes:
- Qualifiers::IgnoringInterferenceByWriter
- Defined in:
- lib/shoulda/matchers/active_model/validation_matcher.rb,
lib/shoulda/matchers/active_model/validation_matcher/build_description.rb
Direct Known Subclasses
ComparisonMatcher, NumericalityMatchers::RangeMatcher, ValidateAbsenceOfMatcher, ValidateAcceptanceOfMatcher, ValidateComparisonOfMatcher, ValidateConfirmationOfMatcher, ValidateExclusionOfMatcher, ValidateInclusionOfMatcher, ValidateLengthOfMatcher, ValidateNumericalityOfMatcher, ValidatePresenceOfMatcher, Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher
Defined Under Namespace
Classes: BuildDescription
Instance Attribute Summary
#ignore_interference_by_writer
Instance Method Summary
collapse
#ignoring_interference_by_writer
Constructor Details
Returns a new instance of ValidationMatcher.
8
9
10
11
12
13
14
15
16
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 8
def initialize(attribute)
super
@attribute = attribute
@expects_strict = false
@subject = nil
@last_submatcher_run = nil
@expected_message = nil
@expects_custom_validation_message = false
end
|
Instance Method Details
#allow_blank ⇒ Object
27
28
29
30
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 27
def allow_blank
options[:allow_blank] = true
self
end
|
#does_not_match?(subject) ⇒ Boolean
59
60
61
62
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 59
def does_not_match?(subject)
@subject = subject
true
end
|
#expects_custom_validation_message? ⇒ Boolean
50
51
52
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 50
def expects_custom_validation_message?
@expects_custom_validation_message
end
|
#expects_strict? ⇒ Boolean
37
38
39
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 37
def expects_strict?
@expects_strict
end
|
#failure_message ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 64
def failure_message
overall_failure_message.dup.tap do |message|
if failure_reason.present?
message << "\n"
message << Shoulda::Matchers.word_wrap(
failure_reason,
indent: 2,
)
end
end
end
|
#failure_message_when_negated ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 76
def failure_message_when_negated
overall_failure_message_when_negated.dup.tap do |message|
if failure_reason.present?
message << "\n"
message << Shoulda::Matchers.word_wrap(
failure_reason,
indent: 2,
)
end
end
end
|
#matches?(subject) ⇒ Boolean
54
55
56
57
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 54
def matches?(subject)
@subject = subject
false
end
|
#on(context) ⇒ Object
22
23
24
25
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 22
def on(context)
@context = context
self
end
|
#strict ⇒ Object
32
33
34
35
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 32
def strict
@expects_strict = true
self
end
|
#with_message(expected_message) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/shoulda/matchers/active_model/validation_matcher.rb', line 41
def with_message(expected_message)
if expected_message
@expects_custom_validation_message = true
@expected_message = expected_message
end
self
end
|