class Object

Public Instance Methods

after(type=nil, &block) click to toggle source
Calls superclass method
# File lib/minitest/around/spec.rb, line 33
def after(type=nil, &block)
  include Module.new { define_method(:teardown) { instance_exec(&block); super() } }
end
around(*args, &block) click to toggle source
  • resume to call first part

  • execute test

  • resume fiber to execute last part

# 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
before(type=nil, &block) click to toggle source
Calls superclass method
# File lib/minitest/around/spec.rb, line 28
def before(type=nil, &block)
  include Module.new { define_method(:setup) { super(); instance_exec(&block) } }
end
run(*args) click to toggle source
# File lib/minitest/around/unit.rb, line 7
def run(*args)
  if defined?(around)
    around { run_without_around(*args) }
  else
    run_without_around(*args)
  end
  self
end