Class: ActiveStorageValidations::Matchers::AttachedValidatorMatcher
- Inherits:
-
Object
- Object
- ActiveStorageValidations::Matchers::AttachedValidatorMatcher
- Includes:
- ActiveStorageable, Contextable, Messageable, Rspecable, Validatable
- Defined in:
- lib/active_storage_validations/matchers/attached_validator_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(attribute_name) ⇒ AttachedValidatorMatcher
constructor
A new instance of AttachedValidatorMatcher.
- #matches?(subject) ⇒ Boolean
Methods included from Rspecable
#failure_message_when_negated, #initialize_rspecable
Methods included from Messageable
#initialize_messageable, #with_message
Methods included from Contextable
Constructor Details
#initialize(attribute_name) ⇒ AttachedValidatorMatcher
Returns a new instance of AttachedValidatorMatcher.
22 23 24 25 26 27 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 22 def initialize(attribute_name) initialize_contextable initialize_rspecable @attribute_name = attribute_name end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 29 def description "validate that :#{@attribute_name} must be attached" end |
#failure_message ⇒ Object
33 34 35 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 33 def "is expected to validate attachment of :#{@attribute_name}" end |
#matches?(subject) ⇒ Boolean
37 38 39 40 41 42 43 44 45 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 37 def matches?(subject) @subject = subject.is_a?(Class) ? subject.new : subject is_a_valid_active_storage_attribute? && is_context_valid? && && is_valid_when_file_attached? && is_invalid_when_file_not_attached? end |