3 class BaseOperatorMatcher
4 attr_reader :generated_description
12 __delegate_method_missing_to_target("==", expected)
17 __delegate_method_missing_to_target("===", expected)
22 __delegate_method_missing_to_target("=~", expected)
27 __delegate_method_missing_to_target(">", expected)
32 __delegate_method_missing_to_target(">=", expected)
37 __delegate_method_missing_to_target("<", expected)
42 __delegate_method_missing_to_target("<=", expected)
45 def fail_with_message(message)
46 Spec::Expectations.fail_with(message, @expected, @target)
51 class PositiveOperatorMatcher < BaseOperatorMatcher #:nodoc:
53 def __delegate_method_missing_to_target(operator, expected)
54 ::Spec::Matchers.generated_description = "should #{operator} #{expected.inspect}"
55 return if @target.send(operator, expected)
56 return fail_with_message("expected: #{expected.inspect},\n got: #{@target.inspect} (using #{operator})") if ['==','===', '=~'].include?(operator)
57 return fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@target.inspect}")
62 class NegativeOperatorMatcher < BaseOperatorMatcher #:nodoc:
64 def __delegate_method_missing_to_target(operator, expected)
65 ::Spec::Matchers.generated_description = "should not #{operator} #{expected.inspect}"
66 return unless @target.send(operator, expected)
67 return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{@target.inspect}")