Sha256: 26b5150d4950e5c4d9fcc0be6d914f7bd07a1fbb437911b44c30274f33d59947
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module DataMapper module Matchers class ValidationMatcher class << self def set_validation_subject(subject) @validation_subject = subject end def set_default_msg_reg(msg_reg) @default_msg_reg = msg_reg end end 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 def with_message(msg) @msg = msg @msg_reg = /^#{Regexp.escape(@msg)}$/ self end def failure_message msg = "expected to validate #{@validation_subject} of #{@property}" msg = %Q'#{msg} with message "#{@msg}"' if @msg msg end def negative_failure_message msg = "expected to not validate #{@validation_subject} of #{@property}" msg = %Q'#{msg} with message "#{@msg}"' if @msg msg end def description "validate #{@validation_subject} of #{@property}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-rspec-0.2.4 | lib/dm/matchers/validation_matcher.rb |
dm-rspec-0.2.3 | lib/dm/matchers/validation_matcher.rb |