This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2017-04-04 18:29:56 -04:00
|
|
|
RSpec::Matchers.define :model_have_error_on_field do |expected|
|
|
|
|
match do |record|
|
|
|
|
if record.errors.empty?
|
|
|
|
record.valid?
|
|
|
|
end
|
|
|
|
|
|
|
|
record.errors.has_key?(expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
failure_message do |record|
|
2022-02-24 08:46:21 -05:00
|
|
|
keys = record.errors.attribute_names
|
2017-11-16 20:52:30 -05:00
|
|
|
|
2017-04-04 18:29:56 -04:00
|
|
|
"expect record.errors(#{keys}) to include #{expected}"
|
|
|
|
end
|
|
|
|
end
|