Sha256: dc5fd6aba20b996b0c69d2d4fd9b0054f1933b5850efb92dbb1f48d119e7be35

Contents?: true

Size: 914 Bytes

Versions: 3

Compression:

Stored size: 914 Bytes

Contents

require 'assert/setup'

module Assert

  # a flag to know if at_exit hook has been installed already
  @@at_exit_installed ||= false

  class << self

    # install at_exit hook (if needed) (runs at process exit)
    # this ensures the test suite won't run unitl all test files are loaded
    # (this is essentially a direct rip from Minitest)
    def autorun
      at_exit do
        # don't run if there was an exception
        next if $!

        # the order here is important. The at_exit handler must be
        # installed before anyone else gets a chance to install their
        # own, that way we can be assured that our exit will be last
        # to run (at_exit stacks).

        exit_code = nil
        at_exit { exit(false) if exit_code && exit_code != 0 }
        self.runner.new(self.suite, self.view).run
      end unless @@at_exit_installed
      @@at_exit_installed = true
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assert-0.6.0 lib/assert/autorun.rb
assert-0.5.0 lib/assert/autorun.rb
assert-0.4.0 lib/assert/autorun.rb