   expects: (method_name) ->
     @_check_expects_usage(method_name)
     @signatures.unshift( new MethodSignature(method_name) )     # .unshift pushes to front of array
-    @[ method_name ] ?= @_define_expected_method(method_name)
+    @[ method_name ] ?= @_build_mocked_method(method_name)
     @_set_state("expects")
     @
     

    @_throw_duplicate_expectation("#{method_name}(#{args})") if @_find_signature(method_name, args...)
        
  _check_for_errors: ->
    errors = @_errors()
    throw errors unless errors == ""
  
  _errors: ->
    errors = ""
    for signature in @signatures when signature.called == false
      errors += "'#{signature.method_name}(#{signature.args})' was never called\n" 
    errors
  
  _set_state: (state) ->
    @state = state
    
  _is_state_in: (states...) ->
    @state in states
  
  _is_reserved: (word) ->
    word in [ "expects", "args", "returns", "check" ]
  
  _throw_expects_usage: ->
    throw "you need to supply a method name to .expects(), e.g. my_mock.expects('my_method')"
  
  _throw_reserved: (reserved) ->
    throw "you cannot do my_mock.expects('#{reserved}'); '#{reserved}' is a reserved method name"
    
  _throw_unknown_expectation: (signature) ->
    throw "#{signature} does not match any expectations"
    
  _throw_args_must_be_after_expects: ->
    throw ".args() must be called immediately after .expects(), e.g. my_mock.expects('my_method').args(42)"
    
  _throw_args_usage: ->
    throw "you need to supply at least one argument to .args(), e.g. my_mock.expects('my_method').args(42)"
    
  _throw_duplicate_expectation: (signature) ->
    throw "#{signature} is a duplicate expectation"
    
  _throw_returns_must_be_after_expects_or_args: ->
    throw ".returns() must be called immediately after .expects() or .args()"
    
  _throw_returns_usage: ->
    throw "you need to supply an argument to .returns(), e.g. my_mock.expects('my_method').returns(123)"

    


mock = (fn) ->
  mocks = ( new Mock() for i in [1..5] )
  fn.apply(undefined, mocks)
  errors = ( mock._build_errors() for mock in mocks ).join("")
  throw errors unless errors == ""


