spec/lib/jspec.js
function(object, method) {
       hook('stubbing', object, method)
       JSpec.stubbed.push(object)
       var type = object.hasOwnProperty(method) ? '__original__' : '__prototype__'
       object[type + method] = object[method]
       object[method] = function(){}
       return {
         and_return : function(value) {
           if (typeof value == 'function') object[method] = value
           else object[method] = function(){ return value }
         }
      }
     }
function(object, method) {
       hook('stubbing', object, method)
       JSpec.stubbed.push(object)
       var type = object.hasOwnProperty(method) ? '__original__' : '__prototype__'
       object[type + method] = object[method]
       object[method] = function(){}
       return {
         and_return : function(value) {
           if (typeof value == 'function') object[method] = value
           else object[method] = function(){ return value }
         }
      }
     }
function ( object , method ) { hook ( 'stubbing' , object , method ) JSpec . stubbed . push ( object ) var type = object . hasOwnProperty ( method ) ? '__original__' : '__prototype__' object [ type + method ] = object [ method ] object [ method ] = function ( ) { } return { and_return : function ( value ) { if ( typeof value == 'function' ) object [ method ] = value else object [ method ] = function ( ) { return value } } } }
Stub _object_'s _method_.

stub(foo, 'toString').and_return('bar')

@param  {mixed} object
@param  {string} method
@return {hash}
@api public
Stub _object_ s _method_ .