Class: ActiveStorageValidations::Matchers::WithAudioValidatorMatcher

Inherits:
Object
  • Object
show all
Includes:
ASVActiveStorageable, ASVAllowBlankable, ASVAttachable, ASVContextable, ASVExceptOnable, ASVMessageable, ASVRspecable, ASVTimeoutable, ASVValidatable
Defined in:
lib/active_storage_validations/matchers/with_audio_validator_matcher.rb

Constant Summary

Constants included from ASVTimeoutable

ASVTimeoutable::UNSET

Instance Method Summary collapse

Methods included from ASVTimeoutable

#initialize_timeoutable, #timeout

Methods included from ASVRspecable

#failure_message_when_negated, #initialize_rspecable

Methods included from ASVMessageable

#initialize_messageable, #with_message

Methods included from ASVExceptOnable

#except_on, #initialize_except_onable

Methods included from ASVContextable

#initialize_contextable, #on

Methods included from ASVAllowBlankable

#allow_blank, #initialize_allow_blankable

Constructor Details

#initialize(attribute_name) ⇒ WithAudioValidatorMatcher

Returns a new instance of WithAudioValidatorMatcher.



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_storage_validations/matchers/with_audio_validator_matcher.rb', line 30

def initialize(attribute_name)
  initialize_allow_blankable
  initialize_contextable
  initialize_except_onable
  initialize_messageable
  initialize_rspecable
  initialize_timeoutable
  @attribute_name = attribute_name
  @expected_audio = true
end

Instance Method Details

#descriptionObject



41
42
43
# File 'lib/active_storage_validations/matchers/with_audio_validator_matcher.rb', line 41

def description
  "validate that :#{@attribute_name} #{audio_expectation}"
end

#failure_messageObject



45
46
47
# File 'lib/active_storage_validations/matchers/with_audio_validator_matcher.rb', line 45

def failure_message
  "is expected to validate that :#{@attribute_name} #{audio_expectation}"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_storage_validations/matchers/with_audio_validator_matcher.rb', line 54

def matches?(subject)
  @subject = subject.is_a?(Class) ? subject.new : subject

  is_a_valid_active_storage_attribute? &&
    is_context_valid? &&
    is_except_on_valid? &&
    is_allowing_blank? &&
    is_timeout_valid? &&
    is_custom_message_valid? &&
    is_valid_with_expected_audio? &&
    is_invalid_with_unexpected_audio?
end

#without_audioObject



49
50
51
52
# File 'lib/active_storage_validations/matchers/with_audio_validator_matcher.rb', line 49

def without_audio
  @expected_audio = false
  self
end