Class: ActiveStorageValidations::Matchers::DimensionValidatorMatcher
Instance Method Summary
collapse
Methods included from Rspecable
#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 DimensionValidatorMatcher.
24
25
26
27
28
29
30
31
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 24
def initialize(attribute_name)
initialize_allow_blankable
initialize_contextable
initialize_messageable
initialize_rspecable
@attribute_name = attribute_name
@width_min = @width_max = @height_min = @height_max = nil
end
|
Instance Method Details
#description ⇒ Object
33
34
35
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 33
def description
"validate the image dimensions of :#{@attribute_name}"
end
|
#failure_message ⇒ Object
37
38
39
40
41
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 37
def failure_message
message = ["is expected to validate dimensions of :#{@attribute_name}"]
build_failure_message(message)
message.join("\n")
end
|
#height(height) ⇒ Object
63
64
65
66
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 63
def height(height)
@height_min = @height_max = height
self
end
|
#height_between(range) ⇒ Object
78
79
80
81
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 78
def height_between(range)
@height_min, @height_max = range.first, range.last
self
end
|
#height_max(height) ⇒ Object
73
74
75
76
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 73
def height_max(height)
@height_max = height
self
end
|
#height_min(height) ⇒ Object
68
69
70
71
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 68
def height_min(height)
@height_min = height
self
end
|
#matches?(subject) ⇒ Boolean
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 83
def matches?(subject)
@subject = subject.is_a?(Class) ? subject.new : subject
is_a_valid_active_storage_attribute? &&
is_context_valid? &&
is_allowing_blank? &&
is_custom_message_valid? &&
width_not_smaller_than_min? &&
width_larger_than_min? &&
width_smaller_than_max? &&
width_not_larger_than_max? &&
width_equals? &&
height_not_smaller_than_min? &&
height_larger_than_min? &&
height_smaller_than_max? &&
height_not_larger_than_max? &&
height_equals?
end
|
#width(width) ⇒ Object
43
44
45
46
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 43
def width(width)
@width_min = @width_max = width
self
end
|
#width_between(range) ⇒ Object
58
59
60
61
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 58
def width_between(range)
@width_min, @width_max = range.first, range.last
self
end
|
#width_max(width) ⇒ Object
53
54
55
56
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 53
def width_max(width)
@width_max = width
self
end
|
#width_min(width) ⇒ Object
48
49
50
51
|
# File 'lib/active_storage_validations/matchers/dimension_validator_matcher.rb', line 48
def width_min(width)
@width_min = width
self
end
|