class DataMapper::Matchers::ValidationMatcher

Public Class Methods

new(property) click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 17
def initialize(property)
  @property = property.to_sym
  @validation_subject = self.class.instance_eval { @validation_subject }
  @msg_reg = self.class.instance_eval { @default_msg_reg }
end
set_default_msg_reg(msg_reg) click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 10
def set_default_msg_reg(msg_reg)
  @default_msg_reg = msg_reg
end
set_validation_subject(subject) click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 6
def set_validation_subject(subject)
  @validation_subject = subject
end

Public Instance Methods

description() click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 41
def description
  "validate #{@validation_subject} of #{@property}"
end
failure_message() click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 29
def failure_message
  msg = "expected to validate #{@validation_subject} of #{@property}"
  msg = %Q'#{msg} with message "#{@msg}"' if @msg
  msg
end
failure_message_when_negated() click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 35
def failure_message_when_negated
  msg = "expected to not validate #{@validation_subject} of #{@property}"
  msg = %Q'#{msg} with message "#{@msg}"' if @msg
  msg
end
with_message(msg) click to toggle source
# File lib/dm/matchers/validation_matcher.rb, line 23
def with_message(msg)
  @msg = msg
  @msg_reg = /^#{Regexp.escape(@msg)}$/
  self
end