You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.10.0
- Add Test::Configuration#skip_coverage to skip test coverage for specific paths + request methods and all responses
- Deprecate setting minimum_coverage value. Use skip_response_coverage, ignored_unknown_status to configure coverage instead.
- Update openapi_parameters to make parsing array query parameters more consistent.
Now parsing empty array query parameter like `ids=&` or `ids&` both result in an empty array value (`[]`) instead of `nil` or `""`.
- Fix Test::Coverage.result returning < 100 even if plan is fully covered
Copy file name to clipboardExpand all lines: README.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,24 +70,49 @@ Here is how to set it up:
70
70
end
71
71
```
72
72
-Or inject a Module to wrap (prepend) the `call` method of your Rack app Class.
73
-
73
+
74
74
NOTE:This is still work in progress. It works with basic Sinatra apps, but does not work with HanamiorRails out of the box, yet. PRs welcome 🤗
75
-
75
+
76
76
```ruby
77
77
OpenapiFirst::Test.observe(MyApplication)
78
78
```
79
79
3. Run your tests. TheCoverage feature will tell you about missing or invalid requests/responses.
80
80
81
81
(✷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.
82
82
83
-
OpenapiFirst' request validation raises an error when a request is not defined. You can deactivate this during testing:
83
+
### Configure test coverage
84
+
85
+
OpenapiFirst::Test raises an error when a request is not defined. You can deactivate this with:
84
86
85
87
```ruby
86
88
OpenapiFirst::Test.setup do |test|
89
+
# …
87
90
test.ignore_unknown_requests = true
88
91
end
89
92
```
90
93
94
+
Exclude certain _responses_ from coverage with `skip_coverage`:
95
+
96
+
```ruby
97
+
OpenapiFirst::Test.setup do |test|
98
+
# …
99
+
test.skip_response_coverage do |response_definition|
100
+
response_definition.status == '5XX'
101
+
end
102
+
end
103
+
```
104
+
105
+
Skip coverage for a request and all responses alltogether of a route with `skip_coverage`:
0 commit comments