mirror of
https://github.com/mastodon/mastodon.git
synced 2024-05-28 23:08:10 +00:00
14 lines
312 B
Ruby
14 lines
312 B
Ruby
RSpec::Matchers.define :model_have_error_on_field do |expected|
|
|
match do |record|
|
|
record.valid? if record.errors.empty?
|
|
|
|
record.errors.has_key?(expected)
|
|
end
|
|
|
|
failure_message do |record|
|
|
keys = record.errors.attribute_names
|
|
|
|
"expect record.errors(#{keys}) to include #{expected}"
|
|
end
|
|
end
|