heroku-client
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -14,2 +14,10 @@ var Heroku = require('./heroku'), | ||
function ParamError (message) { | ||
this.name = 'ParamError'; | ||
this.message = message || ''; | ||
} | ||
ParamError.prototype = Object.create(Error.prototype); | ||
ParamError.prototype.constructor = ParamError; | ||
function buildResource (resource) { | ||
@@ -27,4 +35,9 @@ _.each(resource.actions, function (action, actionName) { | ||
var requestPath = action.path, | ||
pathParams = action.path.match(/{[a-z_]+}/g) || [], | ||
callback; | ||
if (this.params.length !== pathParams.length) { | ||
throw new ParamError('Invalid number of params in path (expected ' + pathParams.length + ', got ' + this.params.length + ').'); | ||
} | ||
this.params.forEach(function (param) { | ||
@@ -31,0 +44,0 @@ requestPath = requestPath.replace(/{[a-z_]+}/, param); |
{ | ||
"name": "heroku-client", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A wrapper for the Heroku v3 API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/heroku.js", |
@@ -116,2 +116,4 @@ # heroku-client [![Build Status](https://travis-ci.org/heroku/node-heroku-client.png?branch=master)](https://travis-ci.org/heroku/node-heroku-client) | ||
Generating docs also runs a cursory test, ensuring that every documented function *is* a function that can be called. | ||
### Running tests | ||
@@ -118,0 +120,0 @@ |
@@ -13,3 +13,3 @@ var Heroku = require('../../lib/heroku'), | ||
it('passes its method into the request', function(done) { | ||
heroku.apps('my-app').create({}, function() { | ||
heroku.apps().create({}, function() { | ||
expect(Request.request.mostRecentCall.args[0].method).toEqual('POST'); | ||
@@ -27,2 +27,10 @@ done(); | ||
describe('requests with the wrong number of parameters', function() { | ||
it('throws an error', function() { | ||
expect(function () { | ||
heroku.apps('my-app').list(); | ||
}).toThrow(new Error('Invalid number of params in path (expected 0, got 1).')); | ||
}); | ||
}); | ||
describe('requests with no body', function() { | ||
@@ -29,0 +37,0 @@ it('can perform a request with no parameters', function(done) { |
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
147442
2498
130