Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created September 22, 2009 03:47
Show Gist options
  • Save cloudhead/190801 to your computer and use it in GitHub Desktop.
Save cloudhead/190801 to your computer and use it in GitHub Desktop.
class Object
def expect m
(class << self; self; end).class_eval do
define_method("#{m}_") do
$expected = true
send("__#{m}__")
end
alias :"__#{m}__" :"#{m}"
alias :"#{m}" :"#{m}_"
end
end
end
class Foo
end
$expected = false
@foo = Foo.new
@foo.expect(:inspect)
@foo.inspect
puts "inspect called on @foo!" if $expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment