lib/dm/matchers/validate_format_of.rb in dm-rspec-0.1.2 vs lib/dm/matchers/validate_format_of.rb in dm-rspec-0.2.0
- old
+ new
@@ -11,10 +11,11 @@
@format = format
self
end
def matches?(model)
- validators = model.validators.contexts[:default]
+ 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