25: def handle_matcher(actual, matcher, &block)
26: ::Spec::Matchers.last_should = "should not"
27: return Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
28:
29: unless matcher.respond_to?(:matches?)
30: raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
31: end
32:
33: unless matcher.respond_to?(:negative_failure_message)
34: Spec::Expectations.fail_with(
35: "Matcher does not support should_not.\nSee Spec::Matchers for more information\nabout matchers.\n"
36: )
37: end
38: match = matcher.matches?(actual, &block)
39: ::Spec::Matchers.last_matcher = matcher
40: Spec::Expectations.fail_with(matcher.negative_failure_message) if match
41: match
42: end