   expects_method = (method_name) ->
     check_usage(@, method_name, arguments.length)
     if not is_mock_method(@[method_name])
-      @[method_name] = new_MockMethod(@, method_name)
-      mock_methods.add(@[method_name])
+      install_mock_method(@, method_name)
     @[method_name].create_expectation()
   
   check_usage = (self, method_name, arg_count) ->

#   fs = require("fs")                                  # a dependency
#   sut = new Sut()                                     # something under test
#   mock ->                                             # start mocking scope: add expects() to Object.prototype
#     fs.expects("writeFileSync").args("some content")  # set an expectation: replace writeFileSync with a mock version
#     sut.do_something_interesting()                    # do whatever it is we want to test
#   ...                                                 # end scope: check expectations, remove expects(), restore original writeFileSync()
#
class MockFunction

    fail(messages.PreExistingProperty, method_name) if has_property(self, method_name)
    fail(messages.ReservedMethodName, method_name) if is_reserved_method_name(method_name)
    
  install_mock_method = (self, method_name) ->
    self[method_name] = new_MockMethod(self, method_name)
    mock_methods.add(self[method_name])
    
  is_mock_method = (method) ->
    mock_methods.contains(method)
    
