Once we call Pacto.generate!
, Pacto will record contracts for all requests it detects.
Now, if we run any code that makes an HTTP call (using an
HTTP library supported by WebMock)
then Pacto will generate a Contract based on the HTTP request/response.
This code snippet will generate a Contract and save it two contracts/api.github.com/repos/thoughtworks/pacto/readme.json
.
We're getting back real data from GitHub, so this should be the actual file encoding.
The generated contract will contain expectations based on the request/response we observed, including a best-guess at an appropriate json-schema. Our heuristics certainly aren't foolproof, so you might want to customize schema!
Here's another sample that sends a post request.
Some generation related configuration.