title: stub a function in Nodejs
body: <p>I have a model stores data into db then calls another store method by passing the id just created</p>
  
  <pre><code> //db.Poll.store method  
  
   store: function (opt, db, callback) {
              var pollData = {
                  question: opt.data.question
              };
  
              db.Poll.create(pollData).success(function (poll) {
                  opt.data.PollId = poll.id;
                  models.PollOption.store(opt, db, callback);
              }).error(function(error) {
                  callback(error, null);
              });
          }
  </code></pre>
  
  <p>I just want to have a unit test to make sure a valid opt.data.PollId is passed to models.PollOption.store() method and I don't want to check if models.PollOption.store() behaviour correctly or not, so I mocked/overwritten the models.PollOption.store method. my unit test is like this below</p>
  
  <pre><code>describe('Method store', function () {
      it('should be able to create a poll and pass poll.id to pollOption.store', function (done) {
          var opt = {
              data: {
                  question: "Do you love nodejs?"
              }
          };
  
          var temp = db.PollOption.store;
          //mock function
          db.PollOption.store = function (opt, db, callback) {
              expect(opt.data.PollId).not.to.be.empty
              //restore to what it was before
              db.PollOption.store = temp;
              callback();
          };
  
          db.Poll.store(opt, db, done);
      });
  });
  </code></pre>
  
  <p>Can I achieve this by using sinon.js , stub db.PollOption.store method? </p>