From fc1605e4a094f55a9288b00a75bdf2200aed38e0 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 7 Aug 2014 14:03:28 +0300 Subject: [PATCH] Create a custom has_errors_on RSpec matcher --- spec/support/matchers/has_errors_on.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spec/support/matchers/has_errors_on.rb diff --git a/spec/support/matchers/has_errors_on.rb b/spec/support/matchers/has_errors_on.rb new file mode 100644 index 0000000..fc00050 --- /dev/null +++ b/spec/support/matchers/has_errors_on.rb @@ -0,0 +1,6 @@ +RSpec::Matchers.define :have_error_on do |expected| + match do |actual| + expect(actual).to_not be_valid + expect(actual.errors.keys).to include expected + end +end