blob: 0f9c81a475a26582603be9a6be2e0750eb70b20e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# frozen_string_literal: true
RSpec::Matchers.define :model_have_error_on_field do |expected|
match do |record|
record.valid? if record.errors.empty?
record.errors.key?(expected)
end
failure_message do |record|
keys = record.errors.attribute_names
"expect record.errors(#{keys}) to include #{expected}"
end
end
|