Class: Module
- Inherits:
-
Object
- Object
- Module
- 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 |
# 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 # https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html # Drop this when we can drop ruby 2.6 (aka after rails 6.1 EOL, ~2024-06) kw_extra = "ruby2_keywords %p" % [new_name] if respond_to? :ruby2_keywords, true self.class_eval " def \#{new_name} *args\n raise \"Calling #\#{new_name} outside of test.\" unless ctx\n case\n when \#{!!dont_flip} then\n ctx.\#{meth}(target, *args)\n when \#{block} && Proc === target then\n ctx.\#{meth}(*args, &target)\n else\n ctx.\#{meth}(args.first, target, *args[1..-1])\n end\n end\n \#{kw_extra}\n EOM\nend\n", __FILE__, __LINE__ + 1 |