class Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher
@private
Attributes
attribute[R]
confirmation_attribute[R]
Public Class Methods
new(attribute)
click to toggle source
Calls superclass method
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 85 def initialize(attribute) super @expected_message = :confirmation @confirmation_attribute = "#{attribute}_confirmation" end
Public Instance Methods
matches?(subject)
click to toggle source
Calls superclass method
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 95 def matches?(subject) super(subject) disallows_different_value && allows_same_value && allows_missing_confirmation end
simple_description()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 91 def simple_description "validate that :#{@confirmation_attribute} matches :#{@attribute}" end
Private Instance Methods
allows_missing_confirmation()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 117 def allows_missing_confirmation allows_value_of('any value') do |matcher| qualify_matcher(matcher, nil) end end
allows_same_value()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 111 def allows_same_value allows_value_of('same value') do |matcher| qualify_matcher(matcher, 'same value') end end
disallows_different_value()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 105 def disallows_different_value disallows_value_of('different value') do |matcher| qualify_matcher(matcher, 'some value') end end
qualify_matcher(matcher, confirmation_attribute_value)
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 123 def qualify_matcher(matcher, confirmation_attribute_value) matcher.values_to_preset = { confirmation_attribute => confirmation_attribute_value } matcher.with_message( @expected_message, against: confirmation_attribute, values: { attribute: attribute } ) end
set_confirmation(value)
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 134 def set_confirmation(value) @last_value_set_on_confirmation_attribute = value AttributeSetter.set( matcher_name: 'confirmation', object: @subject, attribute_name: confirmation_attribute, value: value ) end