title: Sinon Mock of Mongoose Save method for all future instances of a Model (with promises)
body: <p>I am trying to accomplish mocking the Mongoose save method for all instances of a particular Model during a unit test case (Sinon,Mocha, Chai) using promises. I am using sinon-mongoose and sinon-as-promised per several other examples. I am trying to get to something like this end state of test code:</p>
  
  <pre><code>var expect = require('chai').expect;
  var sinon  = require('sinon');
  require('sinon-as-promised');
  require('sinon-mongoose');
  
  /* Mongoose schema+model for User method persist */
  var UserModel = require('./models').userModel;
  /* code module that will be tested */
  var userMethods = require('./user');
  
  /* unit test setup*/
  var userModelMock = sinon.mock(UserModel);
  
  /* mock all instances of UserModel saves with a forced error return to test code modules */        
  userModelMock.expects('save')
           .chain('exec')
           .rejects('error saving');
  
  /* call code module method for testing that creates new instance of UserModel and receives mocked save error*/
  return userMethods.addUser().then(function(result){
      expect(result).to.equal(false);
      userModelMock.restore();
      });
  </code></pre>
  
  <p>I realize the save method is a per instance method so the above mock doesn't work "globally" or within the called addUser() method under test (addUser() doesn't see the mock and hits the database). </p>
  
  <p>Is there some way to reference the Schema Object or other object property to mock all subsequent instances with out creating custom object wrappers or using other esoteric methods? The last answer on this SO post (not the marked answer) comes closest but it only works for a specific instance of a model: <a href="https://stackoverflow.com/questions/16727616/stubbing-a-mongoose-model-using-sinon">Stubbing a Mongoose model using Sinon</a></p>