lib/dm/matchers/validate_presence_of.rb in dm-rspec-0.1.2 vs lib/dm/matchers/validate_presence_of.rb in dm-rspec-0.2.0

- old
+ new

@@ -6,10 +6,12 @@ class ValidatePresenceOf < ValidationMatcher set_validation_subject "presence" def matches?(model) - validators = model.validators.contexts[:default] + model_class = model.is_a?(Class) ? model : model.class + + validators = model_class.validators.contexts[:default] presence_of = validators.find do |validator| validator.is_a? DataMapper::Validations::PresenceValidator and validator.field_name == @property end return false unless presence_of return false if @msg and @msg != presence_of.options[:message]