Class: ActiveStorageValidations::Matchers::AttachedValidatorMatcher
- Inherits:
-
Object
- Object
- ActiveStorageValidations::Matchers::AttachedValidatorMatcher
- Defined in:
- lib/active_storage_validations/matchers/attached_validator_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attribute_name) ⇒ AttachedValidatorMatcher
constructor
A new instance of AttachedValidatorMatcher.
- #matches?(subject) ⇒ Boolean
- #with_message(message) ⇒ Object
Constructor Details
#initialize(attribute_name) ⇒ AttachedValidatorMatcher
Returns a new instance of AttachedValidatorMatcher.
10 11 12 13 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 10 def initialize(attribute_name) @attribute_name = attribute_name @custom_message = nil end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 15 def description "validate #{@attribute_name} must be attached" end |
#failure_message ⇒ Object
29 30 31 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 29 def "is expected to validate attached of #{@attribute_name}" end |
#failure_message_when_negated ⇒ Object
33 34 35 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 33 def "is expected to not validate attached of #{@attribute_name}" end |
#matches?(subject) ⇒ Boolean
24 25 26 27 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 24 def matches?(subject) @subject = subject.is_a?(Class) ? subject.new : subject responds_to_methods && valid_when_attached && invalid_when_not_attached end |
#with_message(message) ⇒ Object
19 20 21 22 |
# File 'lib/active_storage_validations/matchers/attached_validator_matcher.rb', line 19 def () @custom_message = self end |