Skip to content

Commit 438bcbc

Browse files
committed
Rephrase contract testing section of README
1 parent a0d0c3b commit 438bcbc

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Here is how to set it up:
168168
end
169169
```
170170
2. Observe your application. You can do this in multiple ways:
171-
- Add an `app` method to your tests, which wraps your application with silent request / response validation. (✷1)
171+
- Add an `app` method to your tests (which is called by rack-test) that wraps your application with silent request / response validation.
172172
```ruby
173173
module RequestSpecHelpers
174174
def app
@@ -188,9 +188,15 @@ Here is how to set it up:
188188
config.include OpenapiFirst::Test::Methods[MyApp], type: :request
189189
end
190190
```
191-
4. Run your tests. The Coverage feature will tell you about missing or invalid requests/responses.
191+
4. Run your tests. The Coverage feature will tell you about missing or invalid requests/responses:
192+
```
193+
GET /stations
194+
200(application/json)
195+
200(application/xml) – No responses tracked!
196+
400(application/problem+json) – No responses tracked!
197+
```
192198

193-
(✷1): It does not matter what method of openapi_first you use to validate requests/responses. Instead of using `OpenapiFirstTest.app` to wrap your application, you could also use the [middlewares](#rack-middlewares) or [test assertion method](#test-assertions), but you would have to do that for all requests/responses defined in your API description to make coverage work.
199+
Now add tests for all those "" to make them "" and you're green!
194200
195201
> [!NOTE]
196202
> Check out [faraday-openapi](https://codeberg.org/ahx/faraday-openapi) to have your API _client_ validate request/responses against an OAD, which is useful to validate HTTP mocks during testing.

0 commit comments

Comments
 (0)