Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements unified result structure #221

Merged
merged 29 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0c8871b
feat: adds "kind", "values" field properties, removes deprecations
artem-zakharchenko Jun 26, 2019
b940729
test: adjusts Cucumber step definitions to the new vocabulary
artem-zakharchenko Jul 1, 2019
7bfd35e
chore: uses "valid" property in request/response (bin)
artem-zakharchenko Jul 2, 2019
123be20
chore: removes unused step definitions for cucumber tests
artem-zakharchenko Jul 2, 2019
2c31037
test: adjusts test suites to use unified error message format
artem-zakharchenko Jul 2, 2019
8791429
chore: updates readme with the new API
artem-zakharchenko Jul 2, 2019
bc65242
chore: include proper type definition of "location.property" in README
artem-zakharchenko Jul 3, 2019
87bc3f7
chore: introduces "errors[n].location" for body validation results
artem-zakharchenko Jul 3, 2019
8676989
chore: aligns expected/asserted grammar in Gherkin suites
artem-zakharchenko Jul 3, 2019
55ff709
test: adjusts cucumber step definitions to use new vocabulary
artem-zakharchenko Jul 4, 2019
87e6bab
chore: adds inferred json schema notice to README
artem-zakharchenko Jul 4, 2019
19e15e7
test: uses "I" instead of "you" in step definitions
artem-zakharchenko Jul 8, 2019
307016b
fix: simplifies tags handling in cucumber args
artem-zakharchenko Jul 8, 2019
96956ec
chore: moves husky hooks into own config key
artem-zakharchenko Jul 8, 2019
4b24fb6
test: adjusts tests for "error[n].location" property
artem-zakharchenko Jul 8, 2019
48251fd
chore: adapts "actual" namespace in validators
artem-zakharchenko Jul 8, 2019
a95de94
feat: removes diff from TextDiff validator
artem-zakharchenko Jul 8, 2019
c4814e0
chore: updates "gavel-spec" to "4.0.0"
artem-zakharchenko Jul 9, 2019
09bd997
chore: removes "googlediff" package
artem-zakharchenko Jul 9, 2019
3db2db6
test: rewrites TextDiff unit tests
artem-zakharchenko Jul 9, 2019
54d3f12
fix: excludes "@cli" features on win platform
artem-zakharchenko Jul 10, 2019
73b7a95
chore: adds ".nvmrc" and contribution guidelines
artem-zakharchenko Jul 10, 2019
d16d8bf
test: removes unused Cucumber world utils
artem-zakharchenko Jul 11, 2019
feaf319
test: removes surrogate pairs test from TextDiff
artem-zakharchenko Jul 11, 2019
d193fc8
test: declares a proper variable for amanda-to-gavel assertions
artem-zakharchenko Jul 11, 2019
6148b47
chore: marks validators refactoring with GitHub issue
artem-zakharchenko Jul 12, 2019
7ff8e79
chore: removes unused properties from Cucumber world
artem-zakharchenko Jul 12, 2019
d3603f5
chore: provides assertion error messages for "kind" in Chai
artem-zakharchenko Jul 12, 2019
7c67e51
chore: adds license link, adjusts gherkin examples wording in README
artem-zakharchenko Jul 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/cucumber/steps/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { assert } = require('chai');
module.exports = function() {
this.Given(
/^(I record (expected|actual) raw HTTP message:)|(a header is missing in actual message:)$/,
function(_, __, ___, command) {
function(_1, _2, _3, command) {
this.commands.push(command);
}
);
Expand All @@ -12,11 +12,15 @@ module.exports = function() {
'I validate the message using the following Gavel command:',
async function(command) {
this.commands.push(command);
this.status = await this.executeCommands(this.commands);
this.exitCode = await this.executeCommands(this.commands);
}
);

this.Then(/^exit status is (\d+)$/, function(expectedStatus) {
assert.equal(this.status, expectedStatus, 'Process statuses do not match');
this.Then(/^exit status is (\d+)$/, function(expectedExitCode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to change the wording also in the spec for consistency, but let's not bother with this now.

assert.equal(
this.exitCode,
expectedExitCode,
`Expected process to exit with code ${expectedExitCode}, but got ${this.exitCode}.`
);
});
};
2 changes: 1 addition & 1 deletion test/cucumber/steps/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function() {
});

// Vocabulary proxy over the previous action for better scenarios readability.
this.When(/^I call "([^"]*)"$/, function(_command) {
this.When(/^I call "gavel.validate(([^"]*))"$/, function(_, _command) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be gavel.validate\(([^\)]*)\)? Not important if it works correctly like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem to work right now, so we can improve it in #113 :)

this.validate();
});

Expand Down
27 changes: 3 additions & 24 deletions test/cucumber/support/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,15 @@ const HTTP_LINE_DELIMITER = '\n';

class World {
constructor() {
this.codeBuffer = '';
this.commandBuffer = '';

// NEW
this.commands = [];

this.expected = {};
this.actual = {};

// Parsed HTTP objects for model valdiation
this.model = {};

// Gavel validation result
this.results = {};

// CLI: Process exit status
this.status = null;

// Validation verdict for the whole HTTP Message
// this.booleanResult = false;

// Component relevant to the expectation, e.g. 'body'
this.component = null;
this.componentResults = null;
// CLI
this.commands = [];
this.exitCode = null;
}

executeCommands(commands) {
Expand Down Expand Up @@ -107,17 +92,11 @@ Make sure it's in the "Header-Name: value" format.
const [method, uri] = firstLine.split(' ');
parsed.method = method;
parsed.uri = uri;
// firstLine = firstLine.split(' ');
// parsed.method = firstLine[0];
// parsed.uri = firstLine[1];
}

parseResponseLine(parsed, firstLine) {
const [statusCode] = firstLine.split(' ');
parsed.statusCode = statusCode;
// firstLine = firstLine.split(' ');
// parsed.statusCode = firstLine[1];
// parsed.statusMessage = firstLine[2];
}

parseHttp(type, string) {
Expand Down