spec/lib/jspec.xhr.js
function mockRequest() {
    return { and_return : function(body, type, status, headers) {
      XMLHttpRequest = MockXMLHttpRequest
      ActiveXObject = false
      status = status || 200
      headers = headers || {}
      headers['content-type'] = type
      JSpec.extend(XMLHttpRequest.prototype, {
        responseText: body,
        responseHeaders: headers,
        status: status,
        statusText: JSpec.statusCodes[status]
      })
    }}
  }
function mockRequest() {
    return { and_return : function(body, type, status, headers) {
      XMLHttpRequest = MockXMLHttpRequest
      ActiveXObject = false
      status = status || 200
      headers = headers || {}
      headers['content-type'] = type
      JSpec.extend(XMLHttpRequest.prototype, {
        responseText: body,
        responseHeaders: headers,
        status: status,
        statusText: JSpec.statusCodes[status]
      })
    }}
  }
function mockRequest ( ) { return { and_return : function ( body , type , status , headers ) { XMLHttpRequest = MockXMLHttpRequest ActiveXObject = false status = status || 200 headers = headers || { } headers [ 'content-type' ] = type JSpec . extend ( XMLHttpRequest . prototype , { responseText : body , responseHeaders : headers , status : status , statusText : JSpec . statusCodes [ status ] } ) } } }
Mock XMLHttpRequest requests.

mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })

@return {hash}
@api public
Mock XMLHttpRequest requests .