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

Commit

Permalink
Merge pull request #44 from apiaryio/remove-is-validatable
Browse files Browse the repository at this point in the history
Gavel 2 specification
  • Loading branch information
artem-zakharchenko authored Jun 17, 2019
2 parents df7ec67 + 8711aa1 commit 09df9d2
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 547 deletions.
155 changes: 0 additions & 155 deletions features/data_model.feature

This file was deleted.

8 changes: 4 additions & 4 deletions features/expectations/body_json_example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: Body - JSON example
"string": "Hello World"
}
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid

Scenario: Extra key in real JSON body
Expand All @@ -53,7 +53,7 @@ Feature: Body - JSON example
"boolean": true
}
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

Scenario: Different values in real JSON body
Expand All @@ -73,7 +73,7 @@ Feature: Body - JSON example
"boolean": false
}
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

Scenario: Extra array member in real JSON body
Expand All @@ -93,6 +93,6 @@ Feature: Body - JSON example
"string": "Foo bar"
}
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

6 changes: 3 additions & 3 deletions features/expectations/body_json_schema.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Feature: Body - JSON schema draft v4
"string": "Hello World"
}
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

Scenario: Payload body not valid against schema
When real HTTP body is following:
"""
Expand All @@ -57,6 +58,5 @@ Feature: Body - JSON schema draft v4
"string": "Hello World"
}
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid

5 changes: 3 additions & 2 deletions features/expectations/body_json_schemav3.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Feature: Body - JSON schema draft v3
"string": "Hello World"
}
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

Scenario: Payload body not valid against schema
When real HTTP body is following:
"""
Expand All @@ -60,5 +61,5 @@ Feature: Body - JSON schema draft v3
"string": "Hello World"
}
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid
8 changes: 4 additions & 4 deletions features/expectations/body_text_example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Body - text example
One, two, three, four.
Orange, strawberry, banana?
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid

Scenario: Extra line in real payload textual body
Expand All @@ -26,7 +26,7 @@ Feature: Body - text example
Orange, strawberry, banana?
Dog, cat, mouse!
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid

Scenario: Line is changed in real textual body
Expand All @@ -36,7 +36,7 @@ Feature: Body - text example
Orange, strawberry, banana?
Dog, cat, mouse!
"""
Then Gavel will set some error for "body"
Then field "body" is NOT valid
And Request or Response is NOT valid

Scenario: Text in body equals defined example
Expand All @@ -46,6 +46,6 @@ Feature: Body - text example
Orange, strawberry, banana?
Dog, cat, mouse!
"""
Then Gavel will NOT set any errors for "body"
Then field "body" is valid
And Request or Response is valid

8 changes: 4 additions & 4 deletions features/expectations/headers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Headers
"""
Content-Type: text/plain
"""
Then Gavel will set some error for "headers"
Then field "headers" is NOT valid
And Request or Response is NOT valid

@stable
Expand All @@ -30,7 +30,7 @@ Feature: Headers
Location: /here
ETag: 68b329da9893e34099c7d8ad5cb9c940
"""
Then Gavel will NOT set any errors for "headers"
Then field "headers" is valid
And Request or Response is valid

@stable
Expand All @@ -42,7 +42,7 @@ Feature: Headers
Location: /here
ETag: 68b329da9893e34099c7d8ad5cb9c940
"""
Then Gavel will set some error for "headers"
Then field "headers" is NOT valid
And Request or Response is NOT valid

@stable
Expand All @@ -54,7 +54,7 @@ Feature: Headers
Location: /there
ETag: something-completely-different
"""
Then Gavel will NOT set any errors for "headers"
Then field "headers" is valid
And Request or Response is valid


15 changes: 15 additions & 0 deletions features/expectations/method.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@stable
Feature: Method

Background:
Given you expect HTTP message method "POST"

Scenario: HTTP message method match
When real method is "POST"
Then field "method" is valid
And Request or Response is valid

Scenario: Different HTTP message method
When real HTTP message method is "GET"
Then field "method" is NOT valid
And Request or Response is NOT valid
12 changes: 6 additions & 6 deletions features/expectations/status_code.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Feature: Status code
Background:
Given you expect HTTP status code "200"

Scenario: Different real response status
When real status code is "500"
Then Gavel will set some error for "status code"
And Request or Response is NOT valid

Scenario: Response status code match
When real status code is "200"
Then Gavel will NOT set any errors for "status code"
Then field "statusCode" is valid
And Request or Response is valid

Scenario: Different real response status
When real status code is "500"
Then field "statusCode" is NOT valid
And Request or Response is NOT valid
15 changes: 15 additions & 0 deletions features/expectations/uri.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@stable
Feature: URI

Background:
Given you expect HTTP message URI "/animals?type=cats"

Scenario: HTTP message URI match
When real HTTP message URI is "/animals?type=cats"
Then field "uri" is valid
And Request or Response is valid

Scenario: Different HTTP message URI
When real HTTP message URI is "/animals?type=dogs"
Then field "uri" is NOT valid
And Request or Response is NOT valid
13 changes: 4 additions & 9 deletions features/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm install gavel
```javascript
const gavel = require('gavel');

const actualResponse = {
const expectedResponse = {
'statusCode': '200',
'headers': {
'content-type': 'application/json',
Expand All @@ -30,7 +30,8 @@ const actualResponse = {
},
'body': '{\n "origin": "94.113.241.2"\n}'
};
const expectedResponse = {

const realResponse = {
'statusCode': '200',
'headers': {
'content-type': 'application/json',
Expand All @@ -42,13 +43,7 @@ const expectedResponse = {
'body': '{\n "origin": "94.113.241.2"\n}'
};

gavel.isValid(actualResponse, expectedResponse, 'response', (err, result) => {
if (err) {
console.error(err);
} else {
console.log(result);
}
});
const result = gavel.validate(expectedResponse, realResponse);
```

### Command-line interface
Expand Down
Loading

0 comments on commit 09df9d2

Please sign in to comment.