pgte/nock — Issue #27: Can't stub out host when requesting multiple urls for that host
Author: theycallmeswift
Created: 2012-01-05 02:14:14+00:00
State: open

When you stub out a host, any legitimate requests to that host (regardless of the path matching the actual stub or not) cause errors because no matching interception exists.

A quick example:

nock("http://localhost").get("/some/stubbed/path").reply(200, message)
request.get "http://localhost/", (err, res, body) ->
# blah blah blah

This would throw the following error:

Error: Nock: No match for HTTP request GET / undefined

The problem is that the keys in the `allInterceptors` array done by host and a match triggers the `processRequest` function which errors out when no match exists.

I made a simple workaround here: 9330dd26e393ee52dec9c094099cc72e4915fb7c

Unfortunately it's not really complete and causes the tests to fail. A fix would be to check for a complete match before processing the request, but I can't find an easy way to do that. If I can get a better idea of what would be required, I would be happy to put together a pull request when I have some time.