class Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher
@private
Attributes
attribute[R]
confirmation_attribute[R]
Public Class Methods
new(attribute)
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 62 def initialize(attribute) @attribute = attribute @confirmation_attribute = "#{attribute}_confirmation" end
Public Instance Methods
description()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 72 def description "require #{@confirmation_attribute} to match #{@attribute}" end
matches?(subject)
click to toggle source
Calls superclass method
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 76 def matches?(subject) super(subject) @message ||= :confirmation disallows_different_value && allows_same_value && allows_missing_confirmation end
with_message(message)
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 67 def with_message(message) @message = message if message self end
Private Instance Methods
allows_missing_confirmation()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 101 def allows_missing_confirmation set_confirmation(nil) allows_value_of('any value') do |matcher| matcher.with_message(@message, against: error_attribute) end end
allows_same_value()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 94 def allows_same_value set_confirmation('same value') allows_value_of('same value') do |matcher| matcher.with_message(@message, against: error_attribute) end end
disallows_different_value()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 87 def disallows_different_value set_confirmation('some value') disallows_value_of('different value') do |matcher| matcher.with_message(@message, against: error_attribute) end end
error_attribute()
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 115 def error_attribute RailsShim.validates_confirmation_of_error_attribute(self) end
set_confirmation(val)
click to toggle source
# File lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb, line 108 def set_confirmation(val) setter = :"#{@confirmation_attribute}=" if @subject.respond_to?(setter) @subject.__send__(setter, val) end end