test_utils.rb 360 B

123456789101112131415161718192021
  1. module Kernel
  2. # Suppresses any warnings raised in a specified block.
  3. def without_warnings
  4. old_verbose = $VERBOSE
  5. begin
  6. $VERBOSE = nil
  7. yield
  8. ensure
  9. $-v = old_verbose
  10. end
  11. end
  12. def safe_test(level = 1)
  13. thread = Thread.new do
  14. $SAFE = level
  15. yield
  16. end
  17. thread.join
  18. end
  19. end