nock 0.59.0 → 0.59.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/intercept.js CHANGED
@@ -371,7 +371,15 @@ function activate() {
371
371
  });
372
372
 
373
373
  if (! matches && allowUnmocked) {
374
- return overriddenRequest(options, callback);
374
+ if (proto === 'https') {
375
+ var ClientRequest = http.ClientRequest;
376
+ http.ClientRequest = originalClientRequest;
377
+ req = overriddenRequest(options, callback);
378
+ http.ClientRequest = ClientRequest;
379
+ } else {
380
+ req = overriddenRequest(options, callback);
381
+ }
382
+ return req;
375
383
  }
376
384
 
377
385
  // NOTE: Since we already overrode the http.ClientRequest we are in fact constructing
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "0.59.0",
10
+ "version": "0.59.1",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "contributors": [
13
13
  {
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var test = require('tap').test;
4
+ var mikealRequest = require('request');
5
+
6
+ test('allowUnmock for https', function(t) {
7
+ var nock = require('../');
8
+ var scope = nock('https://www.google.com/', {allowUnmocked: true})
9
+ .get('/pathneverhit')
10
+ .reply(200, {foo: 'bar'});
11
+
12
+ var options = {
13
+ method: 'GET',
14
+ uri: 'https://www.google.com'
15
+ };
16
+
17
+ mikealRequest(options, function(err, resp, body) {
18
+ t.notOk(err, 'should be no error');
19
+ t.true(typeof body !== 'undefined', 'body should not be undefined');
20
+ t.true(body.length !== 0, 'body should not be empty');
21
+ t.end();
22
+ return console.log(resp.statusCode, 'body length: ', body.length);
23
+ });
24
+ });