title: Stubbing a class method with Sinon.js
body: <p>I am trying to stub a method using sinon.js but I get the following error:</p>
  
  <p><code>Uncaught TypeError: Attempted to wrap undefined property sample_pressure as function</code></p>
  
  <p>I also went to this question (<a href="https://stackoverflow.com/questions/12819242/stubbing-and-or-mocking-a-class-in-sinon-js">Stubbing and/or mocking a class in sinon.js?</a>) and copied and pasted the code but I get the same error. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>Sensor = (function() {
    // A simple Sensor class
  
    // Constructor
    function Sensor(pressure) {
      this.pressure = pressure;
    }
  
    Sensor.prototype.sample_pressure = function() {
      return this.pressure;
    };
  
    return Sensor;
  
  })();
  
  // Doesn't work
  var stub_sens = sinon.stub(Sensor, "sample_pressure").returns(0);
  
  // Doesn't work
  var stub_sens = sinon.stub(Sensor, "sample_pressure", function() {return 0});
  
  // Never gets this far
  console.log(stub_sens.sample_pressure());
  </code></pre>
  
  <p>Here is the jsFiddle (<a href="http://jsfiddle.net/pebreo/wyg5f/5/" rel="noreferrer">http://jsfiddle.net/pebreo/wyg5f/5/</a>) for the above code, and the jsFiddle for the SO question that I mentioned (<a href="http://jsfiddle.net/pebreo/9mK5d/1/" rel="noreferrer">http://jsfiddle.net/pebreo/9mK5d/1/</a>).</p>
  
  <p>I made sure to include sinon in the <strong>External Resources</strong> in jsFiddle and even jQuery 1.9. What am I doing wrong?</p>