var sinon = require('sinon'),
    sandbox = sinon.sandbox.create();


function getClassProto(_class) {
  /**
   * Get the prototype of a React class.
   *
   * @param {React} _class
   *
   * @return {prototype}
   */

  return _class.type.prototype;
}


function getMethodLocation(_class, method) {
  /**
   * Get the object of which a method is part of.
   *
   * React automagically binds event handlers and stores a cache of them. If we
   * find the method there then we return the cache. Otherwise, we return the
   * class prototype.
   *
   * @param {React} _class
   * @param {String} method
   *
   * @returns {Object}
   */

  var proto = getClassProto(_class);

  if (proto.__reactAutoBindMap[method]) {
    return proto.__reactAutoBindMap;
  }

  return proto;
}


module.exports.spyOnMethod = function(_class, method) {
  /**
   * Spy a method on a React class.
   *
   * Warning: The spy will not call through!
   *
   * @param {React} _class
   * @param {String} method The name of the method you want to spy on.
   *
   * @returns {Spy}
   */

  var methodLoc = getMethodLocation(_class, method);

  return sandbox.spy(methodLoc, method);
};


module.exports.stubMethod = function(_class, method, resp) {
  /**
   * Stub a method on a React class.
   *
   * @param {React} _class
   * @param {String} method The name of the method you want to stub.
   * @param {*} resp The response the stub should return.
   *
   * @returns {Stub}
   */

  var methodLoc = getMethodLocation(_class, method);

  return sandbox.stub(methodLoc, method).returns(resp);
};


afterEach(function() {
  /**
   * Cleanup everything.
   */

  sandbox.restore();
});


@@ -1565,16 +1565,480 @@
 );%0A%7D;%0A%0A%0A
+module.exports.genComponentStub = function(path) %7B%0A  /**%0A   * Create a component stub to be used with proxyquire.%0A   *%0A   * @param %7BString%7D path The module path of the component exactly as it's%0A   *     required in the parent component.%0A   *%0A   * @returns %7BObject.%3CString,React%3E%7D%0A   */%0A%0A  var React = require('react');%0A%0A  var dummy = React.createClass(%7B%0A    render: function() %7B return null; %7D%0A  %7D);%0A%0A  var stubs = %7B%7D;%0A  stubs%5Bpath%5D = dummy;%0A%0A  return stubs;%0A%7D;%0A%0A%0A
 afterEac

Add test helper for generating component stubs