Sha256: 87448ebf3171343001ce93bb0851e7ee452e6849324daa7360d17bb9dc1f4463
Contents?: true
Size: 923 Bytes
Versions: 2
Compression:
Stored size: 923 Bytes
Contents
require 'minitest' require 'minitest/around/version' require 'minitest/around/unit' class Minitest::Spec module DSL # - resume to call first part # - execute test # - resume fiber to execute last part def around(&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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
minitest-around-0.2.0 | lib/minitest/around/spec.rb |
minitest-around-0.2.0.pre3 | lib/minitest/around/spec.rb |