*/
function mockRequest(request) {
var mock = {
listeners : [],
method : 'GET',
headers : [],
uri : {
path : '/',
params : {}
listeners: [],
method: 'GET',
headers: {},
uri: {
path: '/',
params: {}
},
setBodyEncoding : function(type) {
this.bodyEncoding = type
},
*/
function mockResponse(response) {
var mock = {
body : null,
status : 200,
headers : [],
sendHeader : function(){},
sendBody : function(){},
finish : function(){ this.finished = true }
body: null,
status: 200,
headers: [],
sendHeader: function(){},
sendBody: function(){},
finish: function(){ this.finished = true }
}
JSpec.extend(mock, response)
return mock
}
if ((options && options.constructor == Function) || (callback && callback.constructor == Function)) {
return orig.apply(Express, arguments)
}
var request = mockRequest({ method : method.toUpperCase(), uri : { path : path }})
if (options) {
JSpec.extend(request, options.request)
//restore the path, since the mockRequest defaults it to "/"
if (options)
JSpec.extend(request, options.request),
request.uri.path = path
}
var response = mockResponse()
Express.server.callback(request, response)
return Express.response
}