Class: Shoulda::ActiveRecord::Matchers::ValidateAcceptanceOfMatcher

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ValidationMatcher

#failure_message

Instance Method Summary collapse

Methods inherited from ValidationMatcher

#initialize, #negative_failure_message

Constructor Details

This class inherits a constructor from Shoulda::ActiveRecord::Matchers::ValidationMatcher

Instance Method Details

#descriptionObject


33
34
35
# File 'lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb', line 33

def description
  "require #{@attribute} to be accepted"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)

27
28
29
30
31
# File 'lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb', line 27

def matches?(subject)
  super(subject)
  @expected_message ||= :accepted
  disallows_value_of(false, @expected_message)
end

#with_message(message) ⇒ Object


22
23
24
25
# File 'lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb', line 22

def with_message(message)
  @expected_message = message if message
  self
end