Class: ActiveStorageValidations::Matchers::AttachedValidatorMatcher
Instance Method Summary
collapse
#failure_message_when_negated, #initialize_rspecable
#initialize_messageable, #with_message
#initialize_contextable, #on
Constructor Details
24
25
26
27
28
29
|
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 24
def initialize(attribute_name)
initialize_contextable
initialize_messageable
initialize_rspecable
@attribute_name = attribute_name
end
|
Instance Method Details
#description ⇒ Object
31
32
33
|
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 31
def description
"validate that :#{@attribute_name} must be attached"
end
|
#failure_message ⇒ Object
35
36
37
|
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 35
def failure_message
"is expected to validate attachment of :#{@attribute_name}"
end
|
#matches?(subject) ⇒ Boolean
39
40
41
42
43
44
45
46
47
|
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 39
def matches?(subject)
@subject = subject.is_a?(Class) ? subject.new : subject
is_a_valid_active_storage_attribute? &&
is_context_valid? &&
is_custom_message_valid? &&
is_valid_when_file_attached? &&
is_invalid_when_file_not_attached?
end
|