class RSpec::Matchers::BuiltIn::OperatorMatcher

def self.use_custom_matcher_or_delegate(operator)

def self.use_custom_matcher_or_delegate(operator)
  define_method(operator) do |expected|
    if !has_non_generic_implementation_of?(operator) && matcher = OperatorMatcher.get(@actual.class, operator)
      @actual.__send__(::RSpec::Matchers.last_should, matcher.new(expected))
    else
      eval_match(@actual, operator, expected)
    end
  end
  negative_operator = operator.sub(/^=/, '!')
  if negative_operator != operator && respond_to?(negative_operator)
    define_method(negative_operator) do |expected|
      opposite_should = ::RSpec::Matchers.last_should == :should ? :should_not : :should
      raise "RSpec does not support `#{::RSpec::Matchers.last_should} #{negative_operator} expected`.  " +
        "Use `#{opposite_should} #{operator} expected` instead."
    end
  end
end