diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-05 03:31:45 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-05 03:31:45 +0200 |
commit | ccb6a658fd1a2e596c95d5b8e7a39f72a5f5b14b (patch) | |
tree | 7b846b51e3c91fb93aa379361dfe7a811bf5a01c /spec/support | |
parent | 94d00f278819d34ef97d59d17eb289e9be217dfe (diff) | |
parent | 667ffafef8c8b7956cdd31b8f65d5e82778211d8 (diff) |
Merge branch 'fakenine-add_more_tests_to_models'
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/matchers/model/model_have_error_on_field.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/support/matchers/model/model_have_error_on_field.rb b/spec/support/matchers/model/model_have_error_on_field.rb new file mode 100644 index 000000000..5d5fe1c7b --- /dev/null +++ b/spec/support/matchers/model/model_have_error_on_field.rb @@ -0,0 +1,15 @@ +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.keys + + "expect record.errors(#{keys}) to include #{expected}" + end +end |