/*
 * node-http-cache.
 * Copyright © 2012 Chris Corbyn.
 *
 * See LICENSE file for details.
 */

/* Convenience stuff for testing */

module.exports = {
  httpCache: require('../lib/http-cache'),
  http:      require('http'),
  sinon:     require('sinon'),
  memo:      require('memo-is'),

  /** Create a full stub object based on the given prototype */
  stub: function(obj, target) {
    var self = this;
    var cls = (typeof obj == 'function') ? obj.prototype : obj;
    target = target || {};

    Object.getOwnPropertyNames(cls).filter(function(p){
      return typeof cls[p] == 'function';
    }).forEach(function(p) { target[p] = self.sinon.stub() });

    return cls.__proto__ ? this.stub(cls.__proto__, target) : target;
  },

  createRequest: function createRequest(options){
    var req = new this.http.IncomingMessage();
    options = options || {};

    req.method      = options.method      || 'GET';
    req.url         = options.url         || '/';
    req.headers     = options.headers     || {};
    req.httpVersion = options.httpVersion || '1.1';

    return req;
  },

  createResponse: function createResponse(req){
    return new this.http.ServerResponse(req);
  }
};

@@ -378,17 +378,16 @@
  target)
- 
 %7B%0A    va
@@ -409,19 +409,21 @@
     var 
-cls
+proto
  = (type
@@ -487,24 +487,74 @@
  target %7C%7C %7B
+ __proto__: proto, constructor: proto.constructor 
 %7D;%0A%0A    Obje
@@ -576,19 +576,21 @@
 tyNames(
-cls
+proto
 ).filter
@@ -623,19 +623,21 @@
  typeof 
-cls
+proto
 %5Bp%5D == '
@@ -645,16 +645,47 @@
 unction'
+ && typeof %7B%7D%5Bp%5D == 'undefined'
 ;%0A    %7D)
@@ -753,19 +753,21 @@
  return 
-cls
+proto
 .__proto
@@ -785,11 +785,13 @@
 tub(
-cls
+proto
 .__p

Fix a bunch of issues with the stub helper thingo