       expect(requestedUrl).toEqual '/test.html'
       expect(actualOptions).toEqual {host: 'localhost', port: '9000'}
 
+
   it 'should support multiple proxies', ->
     proxy = m.createProxyHandler mockProxy, {'/proxy': 'http://localhost:9000', '/static': 'http://gstatic.com'}
     expect(proxy new httpMock.ServerRequest('/static/test.html'), response).toBeTruthy()

  fsMock = require('mocks').fs
  httpMock = require('mocks').http
  loadFile = require('mocks').loadFile
  actualOptions = requestedUrl = null
  # async helper
  waitForFinishingResponse = ->
    waitsFor (-> response._isFinished()), 'Finish response', 100
  mocks = {}

  beforeEach util.disableLogger

  mocks['http-proxy'] = {}
  globals = process: {}

  m = loadFile __dirname + '/../../lib/proxy.js', mocks, globals

  mockProxy = {}
  mockProxy.on = ->
  mockProxy.proxyRequest = (req, res, opt) ->
    actualOptions = opt
    requestedUrl = req.url
    res.writeHead 200
    res.end 'DONE'
  response = null

  beforeEach ->
    actualOptions = {}
    requestedUrl = ''
    response = new httpMock.ServerResponse

  it 'should proxy requests', ->
    proxy = m.createProxyHandler mockProxy, {'/proxy': 'http://localhost:9000'}

    runs ->
      expect(requestedUrl).toEqual '/test.html'
      expect(actualOptions).toEqual {host: 'gstatic.com', port: '80'}


  it 'should handle nested proxies', ->
    proxy = m.createProxyHandler mockProxy, {'/sub': 'http://localhost:9000', '/sub/some': 'http://gstatic.com/something'}
