Sha256: c1aa3ea6a104011fbead995367902f987090c19a86ab5a6873e7dce906546c3a

Contents?: true

Size: 320 Bytes

Versions: 3

Compression:

Stored size: 320 Bytes

Contents

module DynamicTeardown
  class <<self
    def setup
      stack.push []
    end

    def stack
      @stack ||= []
    end

    def on_teardown(&block)
      stack.last << block
    end

    def teardown
      teardowns = stack.pop
      while td = teardowns.shift
        td.call rescue nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jstorimer-deep-test-2.0.0 infrastructure/dynamic_teardown.rb
jstorimer-deep-test-0.2.0 infrastructure/dynamic_teardown.rb
jstorimer-deep-test-0.1.0 infrastructure/dynamic_teardown.rb