class Proxy
def initialize(target_object)
@object = target_object
@messages = []
end
def method_missing(method_name, *args, &block)
@messages.push method_name
@object.send method_name, *args, &block
end
def messages
@messages
end
def called?(method_name)
@messages.include? method_name
end
def number_of_times_called(method_name)
@messages.select {|x| x == method_name}.size
end
end