mirror of https://github.com/mastodon/mastodon.git
16 lines
326 B
Ruby
16 lines
326 B
Ruby
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|
|
|
keys = record.errors.attribute_names
|
|
|
|
"expect record.errors(#{keys}) to include #{expected}"
|
|
end
|
|
end
|