Comparing version 0.1.5 to 0.1.6
@@ -6,2 +6,4 @@ var path = require('path') | ||
var noop = function() {}; | ||
function startScope(basePath) { | ||
@@ -11,3 +13,4 @@ var interceptors = {} | ||
, transformPathFunction | ||
, transformRequestBodyFunction; | ||
, transformRequestBodyFunction | ||
, logger = noop; | ||
@@ -64,4 +67,6 @@ function add(key, interceptor) { | ||
function match(options, body) { | ||
var method = options.method || 'GET'; | ||
var path = options.path; | ||
var method = options.method || 'GET' | ||
, path = options.path | ||
, matches; | ||
if (transformPathFunction) { path = transformPathFunction(path); } | ||
@@ -74,3 +79,5 @@ if (typeof(body) !== 'string') { | ||
if (body) { matchKey += (' ' + body); } | ||
return matchKey === this._key; | ||
matches = matchKey === this._key; | ||
logger('matching ' + matchKey + ' to ' + this._key + ': ' + matches); | ||
return matches; | ||
} | ||
@@ -165,2 +172,6 @@ | ||
function log(newLogger) { | ||
logger = newLogger; | ||
} | ||
scope = { | ||
@@ -174,2 +185,3 @@ get: get | ||
, filteringRequestBody: filteringRequestBody | ||
, log: log | ||
}; | ||
@@ -176,0 +188,0 @@ |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.1.5" | ||
, "version" : "0.1.6" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "repository" : |
@@ -134,4 +134,12 @@ # Nock | ||
# Logging | ||
Nock can log matches if you pass in a log function like this: | ||
var google = nock('http://google.com') | ||
.log(console.log) | ||
... | ||
# How does it work? | ||
Nock works by overriding Node's http.request function. |
22328
604
144