/usr/lib/ruby/vendor_ruby/minitest/around/spec.rb is in ruby-minitest-around 0.3.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 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 32 33 34 | require 'minitest/spec'
require 'minitest/around/version'
require 'minitest/around/unit'
Minitest::Spec::DSL.class_eval do
# - resume to call first part
# - execute test
# - resume fiber to execute last part
def around(*args, &block)
fib = nil
before do
fib = Fiber.new do |context, resume|
begin
context.instance_exec(resume, &block)
rescue Object
fib = :failed
raise
end
end
fib.resume(self, lambda { Fiber.yield })
end
after { fib.resume unless fib == :failed }
end
# Minitest does not support multiple before/after blocks
def before(type=nil, &block)
include Module.new { define_method(:setup) { super(); instance_exec(&block) } }
end
def after(type=nil, &block)
include Module.new { define_method(:teardown) { instance_exec(&block); super() } }
end
end
|