Skip to content

Instantly share code, notes, and snippets.

Last active Dec 18, 2015
What would you like to do?
errors = [
SystemStackError, LocalJumpError, IOError, RegexpError, ZeroDivisionError,
ThreadError, SystemCallError, SecurityError, RuntimeError, NameError,
RangeError, IndexError, ArgumentError, TypeError
module Kernel
def suppress_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
result = yield
$VERBOSE = original_verbosity
return result
ObjectSpace.each_object do |obj|
m = obj.methods.sample
suppress_warnings {
obj.instance_eval("def #{m}; raise #{errors.sample}; end", obj.method(m).source_location.to_s, rand(100)) if rand(20) < 1 rescue nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment