class DataMapper::Matchers::ValidateFormatOf

Public Instance Methods

failure_message() click to toggle source
# File lib/dm/matchers/validate_format_of.rb, line 27
def failure_message
  msg = "expected to validate #{@validation_subject} of #{@property} with #{@format.inspect}"
  msg = %Q'#{msg} and message "#{@msg}"' if @msg
  msg
end
failure_message_when_negated() click to toggle source
# File lib/dm/matchers/validate_format_of.rb, line 33
def failure_message_when_negated
  msg = "expected to not validate #{@validation_subject} of #{@property} with #{@format.inspect}"
  msg = %Q'#{msg} and message "#{@msg}"' if @msg
  msg
end
matches?(model) click to toggle source
# File lib/dm/matchers/validate_format_of.rb, line 15
def matches?(model)
  model_class = model.is_a?(Class) ? model : model.class
  validators = model_class.validators.contexts[:default]
  format_of = validators.find do |validator|
    validator.is_a? DataMapper::Validations::FormatValidator and validator.field_name == @property
  end
  return false unless format_of
  return false unless format_of.options[:with] == @format
  return false if     @msg and @msg != format_of.options[:message]
  true
end
with(format) click to toggle source
# File lib/dm/matchers/validate_format_of.rb, line 10
def with(format)
  @format = format
  self
end