diff options
author | André Lewin <andre.charles.lewin@gmail.com> | 2017-04-05 20:28:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 20:28:58 +0200 |
commit | bf7cefa516075b480fd5da5ea4b1385d7d17bdd5 (patch) | |
tree | 45bc6b379f5d06553d0a3e5bf4c0e2b452b7552f /spec/support/matchers/model | |
parent | 8736ef50ad13d5506bd6a673d4fcb96c33b609a3 (diff) | |
parent | d13d169922c7efeb6e6c20ef6a271eeda552275f (diff) |
Merge branch 'master' into master
Diffstat (limited to 'spec/support/matchers/model')
-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 |