require 'set' require 'test/unit' class Mock def initialize(class_to_mock=nil) @class_to_mock = class_to_mock @expectations = Set.new end def expects(message) @expectations.add(message) end def verify end def method_missing(method, *args) if (not @expectations.include? method) raise "Unexpected extra call to #{method}" end end end