lib/assert/autorun.rb in assert-0.7.3 vs lib/assert/autorun.rb in assert-0.8.0

- old
+ new

@@ -3,16 +3,18 @@ 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 until all test files are loaded + # (this is essentially a direct rip from Minitest) - # 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 + def self.autorun + if !@@at_exit_installed + self.view.fire(:before_load) + at_exit do # don't run if there was an exception next if $! # the order here is important. The at_exit handler must be @@ -20,14 +22,16 @@ # 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.view.fire(:after_load) self.runner.new(self.suite, self.view).run - end unless @@at_exit_installed + end + @@at_exit_installed = true end - end end