class Module

:nodoc:

def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:

:nodoc:
:nodoc:
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
  block = dont_flip == :block
  dont_flip = false if block
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
  self.class_eval <<-EOM, __FILE__, __LINE__ + 1
    def #{new_name} *args
      Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
    end
  EOM
  Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
    def #{new_name} *args
      case
      when #{!!dont_flip} then
        ctx.#{meth}(target, *args)
      when #{block} && Proc === target then
        ctx.#{meth}(*args, &target)
      else
        ctx.#{meth}(args.first, target, *args[1..-1])
      end
    end
  EOM
end