 
 
 #
-# ExpectsMethod is a function closure used to implement the expects() method:
+# ExpectsMethod is a function closure that implements the expects() method:
 #
 #   mock (m) ->
 #     m.expects("my_method")

  expects_method


MockMethod = (object, method_name) ->

  expectations = new ExpectationList()
  original_method = undefined

  mock_method = (args...) ->
    expectations.check_for_duplicates(method_name)                              # TODO: explain why we do this here
    expectation = expectations.find(args...)
    fail(messages.UnknownExpectation, method_name, args) unless expectation
    expectation._called = yes

  mock_method.find_errors = ->
    expectations.find_errors(method_name)

  # main function body
  mock_method


