-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
254 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"rules": { | ||
"array-bracket-spacing": [2, "never"], | ||
"block-scoped-var": 2, | ||
"brace-style": [2, "1tbs"], | ||
"camelcase": 1, | ||
"computed-property-spacing": [2, "never"], | ||
"curly": 2, | ||
"eol-last": 2, | ||
"eqeqeq": [2, "smart"], | ||
"max-depth": [1, 3], | ||
"max-len": [1, 80], | ||
"max-statements": [1, 15], | ||
"new-cap": 1, | ||
"no-extend-native": 2, | ||
"no-mixed-spaces-and-tabs": 2, | ||
"no-trailing-spaces": 2, | ||
"no-unused-vars": 1, | ||
"no-use-before-define": [2, "nofunc"], | ||
"object-curly-spacing": [2, "never"], | ||
"quotes": [2, "single", "avoid-escape"], | ||
"semi": [2, "always"], | ||
"keyword-spacing": [2, {"before": true, "after": true}], | ||
"space-unary-ops": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"freeze": true, | ||
"indent": 2, | ||
"newcap": true, | ||
"quotmark": "single", | ||
"maxdepth": 3, | ||
"maxstatements": 15, | ||
"maxlen": 80, | ||
"eqnull": true, | ||
"funcscope": true, | ||
"node": true, | ||
"esversion": 6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,73 @@ | ||
/** | ||
* API Routes. | ||
* | ||
* | ||
* @author Chris Spiliotopoulos | ||
*/ | ||
var Joi = require('joi'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var TestsService = require('./services/TestsService'); | ||
|
||
/* | ||
* API routes | ||
*/ | ||
module.exports = function(server) { | ||
|
||
/** | ||
* POST /tests/run | ||
* | ||
* Executes a single BDD test file | ||
*/ | ||
server | ||
.route({ | ||
path : '/tests/run', | ||
method : 'POST', | ||
config : { | ||
tags : [ 'api' ], | ||
description : 'Executes a single BDD test', | ||
notes : 'Upload and execute a BDD test feature file described using the Gherkin3 syntax.', | ||
validate : { | ||
payload : Joi.object().keys({ | ||
'file' : Joi.object().meta({ | ||
swaggerType : 'file' | ||
}).required().description('A file containing a valid test feature written in Gherkin3 syntax'), | ||
'tags' : Joi.string().description('A comma-separated list of @ tags to be executed within the test file, e.g @dev,@test'), | ||
}) | ||
|
||
}, | ||
payload : { | ||
allow : 'multipart/form-data', | ||
output : 'file', | ||
parse : true | ||
}, | ||
handler : function(request, reply) { | ||
|
||
var payload = request.payload; | ||
|
||
// get the request data | ||
var file = payload.file.path; | ||
var tags = payload.tags; | ||
|
||
if (typeof tags !== 'undefined') | ||
tags = decodeURIComponent(tags); | ||
|
||
/* | ||
* Run the test | ||
*/ | ||
TestsService.runTest(file, tags, function(success, logs) { | ||
|
||
return reply(logs).code( (success ? 200 : 400) ); | ||
}); | ||
|
||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
/** | ||
* POST /tests/run | ||
* | ||
* Executes a single BDD test file | ||
*/ | ||
server | ||
.route({ | ||
path: '/tests/run', | ||
method: 'POST', | ||
config: { | ||
tags: ['api'], | ||
description: 'Executes a single BDD test', | ||
notes: 'Upload and execute a BDD test feature file described ' + | ||
' using the Gherkin3 syntax.', | ||
validate: { | ||
payload: Joi.object().keys({ | ||
'file': Joi.object().meta({ | ||
swaggerType: 'file' | ||
}).required().description('A file containing a valid ' + | ||
'test feature written in Gherkin3 syntax'), | ||
'tags': Joi.string().description('A comma-separated list ' + | ||
'of @ tags to be executed within the test file, e.g @dev,@test'), | ||
'format': Joi.string().required() | ||
.valid(['pretty', 'summary', 'json']) | ||
.description('Format to be used for presenting test results') | ||
.default('pretty') | ||
}) | ||
}, | ||
payload: { | ||
allow: 'multipart/form-data', | ||
output: 'file', | ||
parse: true | ||
}, | ||
handler: function(request, reply) { | ||
|
||
var payload = request.payload; | ||
|
||
// get the request data | ||
var file = payload.file.path; | ||
var tags = payload.tags; | ||
var format = payload.format; | ||
|
||
if (typeof tags !== 'undefined') { | ||
tags = decodeURIComponent(tags); | ||
} | ||
|
||
/* | ||
* Run the test | ||
*/ | ||
TestsService.runTest(file, tags, format, function(success, logs) { | ||
|
||
return reply(logs).code((success ? 200 : 400)); | ||
}); | ||
|
||
} | ||
} | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.