Class: Shoulda::Matchers::ActiveModel::ValidateAcceptanceOfMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb

Instance Attribute Summary

Attributes included from Qualifiers::IgnoringInterferenceByWriter

#ignore_interference_by_writer

Instance Method Summary collapse

Methods inherited from ValidationMatcher

#allow_blank, #description, #expects_custom_validation_message?, #expects_strict?, #failure_message, #failure_message_when_negated, #on, #strict, #with_message

Methods included from Qualifiers::IgnoringInterferenceByWriter

#ignoring_interference_by_writer

Constructor Details

#initialize(attribute) ⇒ ValidateAcceptanceOfMatcher

Returns a new instance of ValidateAcceptanceOfMatcher.



84
85
86
87
# File 'lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb', line 84

def initialize(attribute)
  super
  @expected_message = :accepted
end

Instance Method Details

#does_not_match?(subject) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
# File 'lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb', line 94

def does_not_match?(subject)
  super(subject)
  allows_value_of(false, @expected_message)
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
92
# File 'lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb', line 89

def matches?(subject)
  super(subject)
  disallows_value_of(false, @expected_message)
end

#simple_descriptionObject



99
100
101
# File 'lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb', line 99

def simple_description
  %(validate that :#{@attribute} has been set to "1")
end