module ActiveModel::Validations
def errors_on(attribute)
model.should have(n).errors_on(:attribute)
model.should have(1).error_on(:attribute)
model.should have(:no).errors_on(:attribute)
@example
You can also use this to specify the content of the error messages.
model.valid? in order to prepare the object's errors object.
Extension to enhance `should have` on AR Model instances. Calls
def errors_on(attribute) self.valid? [self.errors[attribute]].flatten.compact end