class Object
Public Instance Methods
Source
# File lib/minitest/around/spec.rb, line 33 def after(type=nil, &block) include(Module.new do define_method(:teardown) do begin instance_exec(&block) ensure super() end end end) end
Source
# File lib/minitest/around/spec.rb, line 10 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
-
resume to call first part
-
execute test
-
resume fiber to execute last part
Source
# File lib/minitest/around/spec.rb, line 28 def before(type=nil, &block) include Module.new { define_method(:setup) { super(); instance_exec(&block) } } end
Source
# File lib/minitest/around/unit.rb, line 7 def run(*args) if defined?(around) result = nil around { result = run_without_around(*args) } result else run_without_around(*args) end end