title: Why does this Sinon mock have a mocked method that is not a function?
body: <p>I would like to use test doubles in my coffeescript unit tests to help with separation of concerns.</p>
  
  <p>I am using sinon with mocha (in the context of a Rails app with konacha.)</p>
  
  <p>I am trying what at this point seems straight out of <a href="http://sinonjs.org/docs/#sinon-test">the documentation</a>, which has this example of mock usage:</p>
  
  <pre><code>var myAPI = { method: function () {} };
  
  var spy = sinon.spy();
  var mock = sinon.mock(myAPI);
  mock.expects("method").once().throws();
  
  PubSub.subscribe("message", myAPI.method);
  PubSub.subscribe("message", spy);
  PubSub.publishSync("message", undefined);
  
  mock.verify();
  assert(spy.calledOnce);
  </code></pre>
  
  <p>In my case I'm trying to mock a function call on an object as follows:</p>
  
  <pre><code>canvas = sinon.mock getContext: (arg) -&gt;
  canvas.expects("getContext").once()
  canvas.getContext('2d')
  canvas.verify()
  </code></pre>
  
  <p>This gives a <code>TypeError</code> indicating that <code>getContext</code> is not a function:</p>
  
  <blockquote>
    <p>TypeError: canvas.getContext is not a function</p>
  </blockquote>
  
  <p>The mock seems to be setup and getting verified correctly. When omitting the call to <code>getContext</code>, I am informed that an expectation was not met:</p>
  
  <blockquote>
    <p>ExpectationError: Expected getContext([...]) once (never called)</p>
  </blockquote>
  
  <p>The compiled JavaScript looks like this, then:</p>
  
  <pre><code>var canvas;
  
  canvas = sinon.mock({
    getContext: function(arg) {}
  });
  
  canvas.expects("getContext").once();
  
  canvas.getContext('2d');
  
  canvas.verify();
  </code></pre>
  
  <p>What could account for this error? </p>
  
  <p>I was wondering if I was doing something strange with the function argument, but I can reproduce this without an argument to the <code>getContext</code> call. </p>