Comparing version 0.13.7 to 0.14.0
@@ -23,3 +23,4 @@ var path = require('path') | ||
urlParts = url.parse(basePath), | ||
port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443); | ||
port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443), | ||
persist = false; | ||
@@ -37,2 +38,3 @@ basePath = urlParts.protocol + '//' + urlParts.hostname + ':' + port; | ||
function remove(key, interceptor) { | ||
if (persist) return; | ||
var arr = interceptors[key]; | ||
@@ -168,3 +170,3 @@ if (arr) { | ||
function discard() { | ||
remove(this._key, this); | ||
if (! persist) remove(this._key, this); | ||
} | ||
@@ -302,2 +304,7 @@ | ||
} | ||
function _persist() { | ||
persist = true; | ||
return this; | ||
} | ||
@@ -318,2 +325,3 @@ scope = { | ||
, log: log | ||
, persist: _persist | ||
}; | ||
@@ -320,0 +328,0 @@ |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.13.7" | ||
, "version" : "0.14.0" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "contributors" : |
@@ -39,2 +39,13 @@ # Nock [![Build Status](https://secure.travis-ci.org/flatiron/nock.png)](http://travis-ci.org/flatiron/nock) | ||
## .persist() | ||
You can make all the interceptors for a scope persist by calling `.persist()` on it: | ||
```js | ||
var scope = nock('http://persisssists.con') | ||
.persist() | ||
.get('/') | ||
.reply(200, "Persisting all the way"); | ||
``` | ||
## Specifying request body | ||
@@ -41,0 +52,0 @@ |
@@ -1573,2 +1573,14 @@ var nock = require('../.') | ||
req.end(); | ||
}); | ||
tap.test('persists interceptors', function(t) { | ||
var scope = nock('http://persisssists.con') | ||
.persist() | ||
.get('/') | ||
.reply(200, "Persisting all the way"); | ||
http.get('http://persisssists.con/', function(res) { | ||
t.ok(! scope.isDone()); | ||
t.end(); | ||
}).end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69120
2009
365