Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stick this in your .irbrc and smoke it
def methods_returning(answer, *args)
# probably want to filter out some methods
# e.g. ones that mutate their receiver...
blacklist = %w()
(methods - blacklist).select do |method|
guinea_pig = begin
clone
rescue TypeError => e
raise unless e.message =~ /can't clone/
self
end
begin
guinea_pig.send(method, *args) == answer
rescue ArgumentError, LocalJumpError
rescue TypeError, NoMethodError, NameError, IndexError, SystemCallError, NotImplementedError => e
args_inspected = args.inspect
args_nice = args_inspected[1, args_inspected.length - 2]
puts "#{self.inspect}.#{method}(#{args_nice}) throws #{e.class}: #{e}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.