2013-10-08 05:39:33 +04:00
|
|
|
var _ = require('underscore'),
|
2013-11-03 21:13:19 +04:00
|
|
|
url = require('url'),
|
|
|
|
ApiRouteBase = '/ghost/api/v0.1/',
|
|
|
|
host = 'localhost',
|
|
|
|
port = '2369';
|
|
|
|
schema = "http://"
|
|
|
|
|
|
|
|
function getApiURL (route) {
|
|
|
|
var baseURL = url.resolve(schema + host + ':' + port, ApiRouteBase);
|
|
|
|
return url.resolve(baseURL, route);
|
2013-10-08 05:39:33 +04:00
|
|
|
}
|
2013-11-03 21:13:19 +04:00
|
|
|
function getSigninURL () {
|
|
|
|
return url.resolve(schema + host + ':' + port, 'ghost/signin/');
|
2013-10-08 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 21:13:19 +04:00
|
|
|
// make sure the API only returns expected properties only
|
|
|
|
function checkResponse (jsonResponse, expectedProperties) {
|
|
|
|
Object.keys(jsonResponse).length.should.eql(expectedProperties.length);
|
|
|
|
for(var i=0; i<expectedProperties.length; i = i + 1) {
|
|
|
|
jsonResponse.should.have.property(expectedProperties[i]);
|
2013-10-08 05:39:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 21:13:19 +04:00
|
|
|
module.exports.getApiURL = getApiURL;
|
|
|
|
module.exports.getSigninURL = getSigninURL;
|
|
|
|
module.exports.checkResponse = checkResponse;
|