Contents

Gavel

Behavior spec for Gavel, validator of HTTP transactions

![GitHub repository](https://github.com/apiaryio/gavel-spec) ![npm version](https://badge.fury.io/js/gavel-spec)

Gavel - Validator of HTTP Transactions

What is Gavel?

Gavel detects important differences between actual and expected HTTP transactions (HTTP request and response pairs). Gavel also decides whether the actual HTTP transaction is valid or not.

Input:

Output:

Gavel is useful specifically in testing HTTP APIs. It enables [specification by example][] and [BDD][] approach. The most prominent project built on top of Gavel is [Dredd][], framework which tests HTTP APIs against their documentation.

Implementations

Command-line Interface

Gavel's CLI works well together with curl --trace and the curl-trace-parser utility:

sh
$ curl --trace - http://httpbin.org/ip | curl-trace-parser > expected
$ curl --trace - http://httpbin.org/ip | curl-trace-parser > actual
$ cat actual | gavel expected
$ echo $?
0

To learn more about the CLI, head to the Command-line interface topic.

Expectations

See following paragraphs for a basic overview of how Gavel works. To learn more about the expectations, head to the General validation behavior topic.

Response status

Status code of the expected response must be the same as the one in the actual response.

Request and response headers

For more information see the respective topic.

Request and response body

[Dredd]: https://github.com/apiaryio/dredd [Gavel.js]: https://github.com/apiaryio/gavel.js [specification by example]: http://en.wikipedia.org/wiki/Specification_by_example [BDD]: http://en.wikipedia.org/wiki/Behavior-driven_development

Source: features/README.md at v2.0.0, Gavel (MIT license).