Skip to content

Commit

Permalink
Added logic to allow developers to utilize full request API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fulton Byrne committed Jan 5, 2016
1 parent 55f951c commit 51c9142
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/cradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ cradle.Connection.prototype.rawRequest = function (options, callback) {
options.agent = this.agent;
options.uri = this._url(options.path);
delete options.path;

options = cradle.merge(this.options.request, options);

return request(options, callback || function () { });
};

Expand Down
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
"version": "0.7.0",
"description": "the high-level, caching, CouchDB library",
"url": "http://cloudhead.io/cradle",
"keywords": ["couchdb", "database", "couch"],
"keywords": [
"couchdb",
"database",
"couch"
],
"author": "Alexis Sellier <self@cloudhead.net>",
"contributors": [
{ "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" },
{ "name": "Maciej Malecki", "email": "maciej@nodejitsu.com" }
{
"name": "Charlie Robbins",
"email": "charlie@nodejitsu.com"
},
{
"name": "Maciej Malecki",
"email": "maciej@nodejitsu.com"
}
],
"main": "./lib/cradle",
"dependencies": {
Expand All @@ -17,6 +27,8 @@
},
"devDependencies": {
"async": "~0.9.0",
"proxyquire": "^1.7.3",
"sinon": "^1.17.2",
"vows": "0.8.x"
},
"scripts": {
Expand Down
28 changes: 28 additions & 0 deletions test/raw-request-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var path = require('path'),
assert = require('assert'),
events = require('events'),
vows = require('vows'),
sinon = require('sinon'),
proxyquire = require('proxyquire');

var reqSpy = sinon.spy();
var cradle = proxyquire('../lib/cradle', {
request: reqSpy
});

vows.describe('cradle/raw-request').addBatch({
'Options specified in "request" are passed directly to request library': {
topic: new(cradle.Connection)({ request: { someOption: 'filler' }}),
'should pass through values to "request"': function(topic) {
var args;
var opts = {
moreOptions: 'moreFiller',
path: 'path'
};
topic.rawRequest(opts);
args = reqSpy.getCall(0).args[0];
assert(args.moreOptions, 'moreFiller');
assert(args.someOption, 'filler');
}
}
}).export(module);

0 comments on commit 51c9142

Please sign in to comment.