Sorry for late answer. Minitests are artful.
minitest/autorun
uses at_exit method. It executes the given block when interpreter's work almost done. Roughly speaking "at the end" of your program's lifetime. Though you can call at_exit
method more than once and blocks will execute in LIFO order.
More interesting details about at_exit
and its usage you can find here.
Also you may look at minitests source code. (in this file at_exit
called)
Good luck!