Class: Spec::Expectations::NegativeExpectationMatcherHandler

Inherits:
Object
  • Object
show all
Extended by:
MatcherHandlerHelper
Defined in:
lib/spec/expectations/handler.rb

Class Method Summary collapse

Methods included from MatcherHandlerHelper

describe

Class Method Details

.handle_matcher(actual, matcher, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/spec/expectations/handler.rb', line 24

def handle_matcher(actual, matcher, &block)
  unless matcher.respond_to?(:negative_failure_message)
    Spec::Expectations.fail_with(
<<-EOF
Matcher does not support should_not.
See Spec::Matchers for more information
about matchers.
EOF
)
  end
  match = matcher.matches?(actual, &block)
  ::Spec::Matchers.generated_description = "should not #{describe(matcher)}"
  Spec::Expectations.fail_with(matcher.negative_failure_message) if match
end