Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Implements v2 #178

Merged
merged 27 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
33dc9b8
feat: removes "isValidatable" from public API
artem-zakharchenko May 30, 2019
f0960fe
test: removes "isValidatable" test suites
artem-zakharchenko May 30, 2019
807a879
feat: stops using "isValid" internally
artem-zakharchenko May 31, 2019
969ab5a
feat: removes "isValid" from public API
artem-zakharchenko May 31, 2019
4a4e9a3
feat: removes "type" parameter from "validate" call signature
artem-zakharchenko May 31, 2019
2c36cbb
feat: removes HttpRequest, HttpResponse, and Validatable
artem-zakharchenko Jun 3, 2019
a7a0074
test: aligns test suites for gavel-spec v2
artem-zakharchenko Jun 4, 2019
e5c4f72
feat: adds "method" field validation
artem-zakharchenko Jun 4, 2019
290dec8
feat: removes "severity" from error messages
artem-zakharchenko Jun 5, 2019
de99480
refactor: adjusts methods and tests to be compliant with the next spec
artem-zakharchenko Jun 5, 2019
01503a0
chore: exports gavel directly from lib/
artem-zakharchenko Jun 5, 2019
f631116
feat: swaps the order of "real" and "expected" arguments (validate)
artem-zakharchenko Jun 5, 2019
681b032
feat: removes "callback" argument of "validate"
artem-zakharchenko Jun 5, 2019
8270f29
chore: removes unnecessary modules nesting around "validateMessage"
artem-zakharchenko Jun 5, 2019
818d1d2
test: removes "sets some errors for X" criteria handling (cucumber)
artem-zakharchenko Jun 6, 2019
4478590
refactor: introduces "otherwise" logic util
artem-zakharchenko Jun 6, 2019
f08d0a6
feat: validates "uri" field of HTTP message
artem-zakharchenko Jun 6, 2019
7344f12
fix: validates relative URI
artem-zakharchenko Jun 6, 2019
b8ae32e
chore: uses "*.test.js" pattern for tests
artem-zakharchenko Jun 6, 2019
8f0a170
chore: moves all tests under "test/" dir
artem-zakharchenko Jun 6, 2019
4748564
fix: uses new call signature of "validate()" in cli
artem-zakharchenko Jun 10, 2019
1dfeab4
feat: validates query parameters (validateURI)
artem-zakharchenko Jun 11, 2019
329759b
test: asserts feature snippet and parsed data in "data_model" tests
artem-zakharchenko Jun 11, 2019
459c4e8
chore: updates "gavel-spec" to version 3
artem-zakharchenko Jun 17, 2019
7870a99
fix: improves explanatory comments
artem-zakharchenko Jun 17, 2019
c830ff6
fix: adjusts namespaces and call signatures of "isValid" utils
artem-zakharchenko Jun 17, 2019
5bd3333
fix: uses native "url" module for URI parsing
artem-zakharchenko Jun 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'consistent-return': 'off',
'class-methods-use-this': 'off',
'no-plusplus': 'off',
'func-names': 'off',

// Temporary overrides. Logic to be rewritten.
// TODO https://github.com/apiaryio/gavel.js/issues/150
Expand Down
30 changes: 9 additions & 21 deletions bin/gavel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env node
/* eslint-disable */

var cmd = require('commander');
var httpParser = require('http-string-parser');
var curlParser = require('curl-trace-parser');
var gavel = require('../lib/gavel');
var gavel = require('../lib');
var fs = require('fs');

cmd.version('0.0.1');
Expand All @@ -23,29 +24,16 @@ process.stdin.on('end', function() {

var realHttp = curlParser.parseBack(stdin);

var realRequest = httpParser.parseRequest(realHttp['request']);
var realResponse = httpParser.parseResponse(realHttp['response']);
var realRequest = httpParser.parseRequest(realHttp.request);
var realResponse = httpParser.parseResponse(realHttp.response);

var expectedRequest = httpParser.parseRequest(expectedHttp['request']);
var expectedResponse = httpParser.parseResponse(expectedHttp['response']);
var expectedRequest = httpParser.parseRequest(expectedHttp.request);
var expectedResponse = httpParser.parseResponse(expectedHttp.response);

var requestResult = false;
var responseResult = false;
const requestResult = gavel.validate(expectedRequest, realRequest);
const responseResult = gavel.validate(expectedResponse, realResponse);

gavel.isValid(realRequest, expectedRequest, 'request', function(
err,
result
) {
requestResult = result;
gavel.isValid(realResponse, expectedResponse, 'response', function(
err,
result
) {
responseResult = result;
});
});

if (requestResult && responseResult) {
if (requestResult.isValid && responseResult.isValid) {
process.exit(0);
} else {
process.exit(1);
Expand Down
17 changes: 0 additions & 17 deletions lib/gavel.js

This file was deleted.

5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { validate } = require('./validate');

module.exports = {
validate
};
Loading