File: global_must.rb

package info (click to toggle)
ruby-maxitest 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 536 kB
  • sloc: ruby: 1,578; makefile: 7
file content (18 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Allow global must_* assertion style without deprecations
#
# Must be required before maxitest/autorun
Module.prepend(Module.new do
  def infect_an_assertion(_, new_name, *)
    super # define with deprecation

    # remove old to avoid warnings from re-defining
    remove_method new_name

    # re-define without deprecation
    class_eval <<-EOM, __FILE__, __LINE__ + 1
      def #{new_name} *args
        Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
      end
    EOM
  end
end)