Skip to content

Instantly share code, notes, and snippets.


Carl Suster arcresu

  • Sydney, Australia
View GitHub Profile
peterc / methods_returning.rb
Last active Jun 19, 2021
Object#methods_returning - to work out which method on an object returns what we want
View methods_returning.rb
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false