Class: Module

Inherits:
Object show all
Defined in:
lib/minitest/spec.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#infect_an_assertion(meth, new_name, dont_flip = false) ⇒ Object

:nodoc:


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/minitest/spec.rb', line 4

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 "def \#{new_name} *args\nwhere = Minitest.filter_backtrace(caller).first\nwhere = where.split(/:in /, 2).first # clean up noise\nwarn \"DEPRECATED: global use of \#{new_name} from #\\{where}. Use _(obj).\#{new_name} instead. This will fail in Minitest 6.\"\nMinitest::Expectation.new(self, Minitest::Spec.current).\#{new_name}(*args)\nend\n", __FILE__, __LINE__ + 1

  Minitest::Expectation.class_eval "def \#{new_name} *args\nraise \"Calling #\#{new_name} outside of test.\" unless ctx\ncase\nwhen \#{!!dont_flip} then\nctx.\#{meth}(target, *args)\nwhen \#{block} && Proc === target then\nctx.\#{meth}(*args, &target)\nelse\nctx.\#{meth}(args.first, target, *args[1..-1])\nend\nend\n", __FILE__, __LINE__ + 1
end