From 56731445273bccf2b6df8023cc3c04ce2b4bc3ed Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 5 Jan 2020 23:01:25 -0700 Subject: [PATCH] Fix negative match case for contain/cover matcher --- src/spectator/matchers/contain_matcher.cr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/spectator/matchers/contain_matcher.cr b/src/spectator/matchers/contain_matcher.cr index edecfbd..c009851 100644 --- a/src/spectator/matchers/contain_matcher.cr +++ b/src/spectator/matchers/contain_matcher.cr @@ -18,6 +18,13 @@ module Spectator::Matchers end end + # If the expectation is negated, then this method is called instead of `#match?`. + private def does_not_match?(actual : TestExpression(T)) : Bool forall T + !expected.value.any? do |item| + actual.value.includes?(item) + end + end + # Message displayed when the matcher isn't satisifed. # # This is only called when `#match?` returns false.