Class: ActiveStorageValidations::Matchers::LimitValidatorMatcher
Instance Method Summary
collapse
#failure_message_when_negated, #initialize_rspecable
#initialize_messageable, #with_message
#initialize_contextable, #on
#allow_blank, #initialize_allow_blankable
Constructor Details
Returns a new instance of LimitValidatorMatcher.
26
27
28
29
30
31
32
33
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 26
def initialize(attribute_name)
initialize_allow_blankable
initialize_contextable
initialize_messageable
initialize_rspecable
@attribute_name = attribute_name
@min = @max = nil
end
|
Instance Method Details
#description ⇒ Object
35
36
37
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 35
def description
"validate the limit files of :#{@attribute_name}"
end
|
#failure_message ⇒ Object
39
40
41
42
43
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 39
def failure_message
message = ["is expected to validate limit file of :#{@attribute_name}"]
build_failure_message(message)
message.join("\n")
end
|
#matches?(subject) ⇒ Boolean
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 55
def matches?(subject)
@subject = subject.is_a?(Class) ? subject.new : subject
is_a_valid_active_storage_attribute? &&
is_context_valid? &&
is_custom_message_valid? &&
file_count_not_smaller_than_min? &&
file_count_equal_min? &&
file_count_larger_than_min? &&
file_count_smaller_than_max? &&
file_count_equal_max? &&
file_count_not_larger_than_max?
end
|
#max(count) ⇒ Object
50
51
52
53
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 50
def max(count)
@max = count
self
end
|
#min(count) ⇒ Object
45
46
47
48
|
# File 'lib/active_storage_validations/matchers/limit_validator_matcher.rb', line 45
def min(count)
@min = count
self
end
|