fitting 2.11.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +47 -0
- data/README.md +136 -76
- data/fitting.gemspec +1 -1
- data/lib/fitting.rb +5 -0
- data/lib/fitting/cover/json_schema.rb +21 -80
- data/lib/fitting/cover/json_schema_enum.rb +20 -70
- data/lib/fitting/cover/json_schema_one_of.rb +38 -0
- data/lib/fitting/records/spherical/requests.rb +3 -1
- data/lib/fitting/records/unit/json_schema.rb +26 -0
- data/lib/fitting/report/action.rb +53 -0
- data/lib/fitting/report/actions.rb +55 -0
- data/lib/fitting/report/combination.rb +37 -0
- data/lib/fitting/report/combinations.rb +47 -0
- data/lib/fitting/report/console.rb +41 -0
- data/lib/fitting/report/prefix.rb +53 -0
- data/lib/fitting/report/prefixes.rb +44 -0
- data/lib/fitting/report/response.rb +71 -0
- data/lib/fitting/report/responses.rb +48 -0
- data/lib/fitting/report/test.rb +61 -0
- data/lib/fitting/report/tests.rb +62 -0
- data/lib/fitting/statistics/cover_error_one_of.rb +27 -0
- data/lib/fitting/statistics/list.rb +2 -0
- data/lib/fitting/statistics/measurement_cover_one_of.rb +92 -0
- data/lib/fitting/statistics/template.rb +5 -0
- data/lib/fitting/statistics/template_cover_error_one_of.rb +50 -0
- data/lib/fitting/tests.rb +0 -1
- data/lib/fitting/version.rb +1 -1
- data/lib/tasks/fitting.rake +150 -2
- data/lib/templates/bomboniere/.gitignore +21 -0
- data/lib/templates/bomboniere/.tool-versions +1 -0
- data/lib/templates/bomboniere/README.md +19 -0
- data/lib/templates/bomboniere/dist/css/app.62e086ac.css +1 -0
- data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
- data/lib/templates/bomboniere/dist/favicon.ico +0 -0
- data/lib/templates/bomboniere/dist/index.html +1 -0
- data/lib/templates/bomboniere/dist/js/app.4356d509.js +2 -0
- data/lib/templates/bomboniere/dist/js/app.4356d509.js.map +1 -0
- data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js +13 -0
- data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js.map +1 -0
- data/lib/templates/bomboniere/package-lock.json +9263 -0
- data/lib/templates/bomboniere/package.json +25 -0
- data/lib/templates/bomboniere/public/favicon.ico +0 -0
- data/lib/templates/bomboniere/public/index.html +17 -0
- data/lib/templates/bomboniere/src/App.vue +102 -0
- data/lib/templates/bomboniere/src/assets/logo.png +0 -0
- data/lib/templates/bomboniere/src/components/HelloWorld.vue +188 -0
- data/lib/templates/bomboniere/src/main.js +10 -0
- data/lib/templates/bomboniere/src/router/index.js +31 -0
- data/lib/templates/bomboniere/src/views/About.vue +5 -0
- data/lib/templates/bomboniere/src/views/Action.vue +154 -0
- data/lib/templates/bomboniere/src/views/Home.vue +17 -0
- data/lib/templates/bomboniere/vue.config.js +3 -0
- metadata +47 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 036f174c7154d494520197fefae664cf6086fb47feaad76f091d25f194016ce8
|
4
|
+
data.tar.gz: 339e5f12a4a85e86f10bb112bdf23231d9f0af5bbc6a2fba0145f344a37802da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde3886c4f56bcab60b00f91f0a3c129676f430b2c3c5c3687a08fe28c207474e3076d21780e8f9adb2a2c6f6e0bc02f490a4101d77394ed2d92ec5f9687f9cd
|
7
|
+
data.tar.gz: f2d6bc93bed0cfe10d0fadb3bb528e837cb4b9867e479991e2f71f772f961113a937c9559903435b55b64d3c2993a275872b804f31fb09c077d252db7d9fb8b2
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.3.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,52 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
### 2.14.0 - 2020-09-18
|
4
|
+
|
5
|
+
* features
|
6
|
+
* save tests for all prefixes [#35](https://github.com/funbox/fitting/issues/35)
|
7
|
+
* prefix checking [#37](https://github.com/funbox/fitting/issues/37)
|
8
|
+
* html view for prefix checking [#39](https://github.com/funbox/fitting/issues/39)
|
9
|
+
* add actions join in new html report [#41](https://github.com/funbox/fitting/issues/41)
|
10
|
+
* add responses join in new report [#43](https://github.com/funbox/fitting/issues/43)
|
11
|
+
* add combinations join in new report [#47](https://github.com/funbox/fitting/issues/47)
|
12
|
+
* add action page [#49](https://github.com/funbox/fitting/issues/49)
|
13
|
+
* show more information in new report [#51](https://github.com/funbox/fitting/issues/51)
|
14
|
+
* add accordion for prefixes [#55](https://github.com/funbox/fitting/issues/55)
|
15
|
+
* move json-schemas to separate files [#57](https://github.com/funbox/fitting/issues/57)
|
16
|
+
* add method for tests without actions [#61](https://github.com/funbox/fitting/issues/61)
|
17
|
+
* show tests without responses [#63](https://github.com/funbox/fitting/issues/63)
|
18
|
+
* add console output for new report [#69](https://github.com/funbox/fitting/issues/69)
|
19
|
+
* check test in new console [#71](https://github.com/funbox/fitting/issues/71)
|
20
|
+
* fixes
|
21
|
+
* fix vulnerability CVE-2020-7660 [#53](https://github.com/funbox/fitting/issues/53)
|
22
|
+
* fix cover if response without combinations [#59](https://github.com/funbox/fitting/issues/59)
|
23
|
+
* fix cover if combinations without tests [#66](https://github.com/funbox/fitting/issues/66)
|
24
|
+
* do not check tests without combinations [#73](https://github.com/funbox/fitting/issues/73)
|
25
|
+
|
26
|
+
### 2.13.1 - 2020-04-17
|
27
|
+
|
28
|
+
* fixes
|
29
|
+
* combinations
|
30
|
+
|
31
|
+
### 2.13.0 - 2020-02-26
|
32
|
+
|
33
|
+
* features
|
34
|
+
* use request tests
|
35
|
+
|
36
|
+
* patch
|
37
|
+
* improve combination name for enum cover
|
38
|
+
* improve combination name for required cover
|
39
|
+
|
40
|
+
### 2.12.1 - 2020-02-07
|
41
|
+
|
42
|
+
* fixes
|
43
|
+
* oneOf
|
44
|
+
|
45
|
+
### 2.12.0 - 2019-09-10
|
46
|
+
|
47
|
+
* features
|
48
|
+
* Add l size (for cover oneOf in json-schema) in rake tasks fitting:documentation_responses, fitting:documentation_responses_error
|
49
|
+
|
3
50
|
### 2.11.0 - 2019-09-09
|
4
51
|
|
5
52
|
* features
|
data/README.md
CHANGED
@@ -1,40 +1,42 @@
|
|
1
1
|
# Fitting
|
2
2
|
|
3
|
-
<a href="https://funbox.ru">
|
4
|
-
<img src="https://funbox.ru/badges/sponsored_by_funbox_compact.svg" alt="Sponsored by FunBox" width=250 />
|
5
|
-
</a>
|
6
|
-
|
7
3
|
[![Gem Version](https://badge.fury.io/rb/fitting.svg)](https://badge.fury.io/rb/fitting)
|
8
4
|
[![Build Status](https://travis-ci.org/funbox/fitting.svg?branch=master)](https://travis-ci.org/funbox/fitting)
|
9
5
|
|
10
6
|
This gem will help you implement your API in strict accordance to the documentation in [API Blueprint](https://apiblueprint.org/) format.
|
11
|
-
To do this, when you run your RSpec tests on controllers, it automatically searches for the corresponding
|
7
|
+
To do this, when you run your RSpec tests on controllers, it automatically searches for the corresponding JSON-schemas in the documentation and then validates responses with them.
|
12
8
|
|
13
9
|
## Installation
|
14
10
|
|
15
|
-
|
11
|
+
First you need to install [drafter](https://github.com/apiaryio/drafter).
|
12
|
+
|
13
|
+
Then add this line to your application's Gemfile:
|
16
14
|
|
17
15
|
```ruby
|
18
16
|
gem 'fitting'
|
19
17
|
```
|
20
18
|
|
21
|
-
|
19
|
+
After that execute:
|
22
20
|
|
23
|
-
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
24
24
|
|
25
|
-
Or install
|
25
|
+
Or install the gem by yourself:
|
26
26
|
|
27
|
-
|
27
|
+
```bash
|
28
|
+
$ gem install fitting
|
29
|
+
```
|
28
30
|
|
29
31
|
## Usage
|
30
32
|
|
31
|
-
|
33
|
+
Add this to your `.fitting.yml`:
|
32
34
|
|
33
35
|
```yaml
|
34
36
|
apib_path: /path/to/doc.apib
|
35
37
|
```
|
36
38
|
|
37
|
-
|
39
|
+
And this to your `spec_helper.rb`:
|
38
40
|
|
39
41
|
```ruby
|
40
42
|
require 'fitting'
|
@@ -42,11 +44,11 @@ require 'fitting'
|
|
42
44
|
Fitting.save_test_data
|
43
45
|
```
|
44
46
|
|
45
|
-
The files will be created in
|
47
|
+
The result files will be created in `./fitting_tests/` folder.
|
46
48
|
|
47
|
-
|
49
|
+
Output example:
|
48
50
|
|
49
|
-
```
|
51
|
+
```json
|
50
52
|
[
|
51
53
|
{
|
52
54
|
"method": "GET",
|
@@ -73,20 +75,45 @@ Example:
|
|
73
75
|
},
|
74
76
|
"title": "/spec/controllers/api/v1/books_controller_spec.rb:22",
|
75
77
|
"group": "/spec/controllers/api/v1/books_controller_spec.rb"
|
76
|
-
}
|
77
|
-
|
78
|
+
}
|
79
|
+
]
|
78
80
|
```
|
79
81
|
|
82
|
+
## Documentation coverage
|
83
|
+
|
84
|
+
To match routes and validate JSON-schemas run:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
rake fitting:documentation_responses[report_size]
|
88
|
+
```
|
80
89
|
|
81
|
-
|
90
|
+
There are four types (or `report_size`) of reports available:
|
91
|
+
|
92
|
+
- `xs` — the smallest report;
|
93
|
+
- `s` — includes coverage for `required` fields;
|
94
|
+
- `m` — includes coverage for `required` and `enum` fields;
|
95
|
+
- `l` — includes coverage for `required`, `enum` and `oneOf` fields.
|
82
96
|
|
83
|
-
|
97
|
+
E.g. for `xs` size:
|
84
98
|
|
85
|
-
|
99
|
+
```bash
|
100
|
+
rake fitting:documentation_responses[xs]
|
101
|
+
```
|
86
102
|
|
87
|
-
|
103
|
+
**Note**: In zsh you should add quotes around the task:
|
88
104
|
|
105
|
+
```bash
|
106
|
+
rake 'fitting:documentation_responses[xs]'
|
89
107
|
```
|
108
|
+
|
109
|
+
Also you can use `documentation_responses_error` to get more detailed errors description.
|
110
|
+
Check the examples below.
|
111
|
+
|
112
|
+
### Examples
|
113
|
+
|
114
|
+
`xs` size:
|
115
|
+
|
116
|
+
```text
|
90
117
|
Fully conforming requests:
|
91
118
|
DELETE /api/v1/book ✔ 200 ✔ 201 ✔ 404
|
92
119
|
DELETE /api/v1/book/{id} ✔ 200 ✔ 201 ✔ 404
|
@@ -110,11 +137,9 @@ API responses conforming to the blueprint: 16 (64.00% of 25).
|
|
110
137
|
API responses with validation errors or untested: 9 (36.00% of 25).
|
111
138
|
```
|
112
139
|
|
113
|
-
|
114
|
-
|
115
|
-
In addition to the previous comand, you will learn the coverage(required) json-schemas with task `rake fitting:documentation_responses[s]`
|
140
|
+
`s` size:
|
116
141
|
|
117
|
-
```
|
142
|
+
```text
|
118
143
|
Fully conforming requests:
|
119
144
|
DELETE /api/v1/book 100% 200 100% 201 100% 404
|
120
145
|
DELETE /api/v1/book/{id} 100% 200 100% 201 100% 404
|
@@ -138,7 +163,7 @@ API responses conforming to the blueprint: 16 (64.00% of 25).
|
|
138
163
|
API responses with validation errors or untested: 9 (36.00% of 25).
|
139
164
|
```
|
140
165
|
|
141
|
-
|
166
|
+
`documentation_responses_error[s]` example:
|
142
167
|
|
143
168
|
```
|
144
169
|
request method: GET
|
@@ -149,63 +174,79 @@ combination: ["required", "pages"]
|
|
149
174
|
new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
|
150
175
|
```
|
151
176
|
|
152
|
-
###
|
177
|
+
### Experimental report
|
178
|
+
|
179
|
+
This report will be available and properly documented in the next major update, but you already can try it by running:
|
153
180
|
|
154
|
-
|
155
|
-
|
181
|
+
```bash
|
182
|
+
bundle e rake fitting:report
|
183
|
+
```
|
184
|
+
|
185
|
+
Using this you can document API prefixes.
|
186
|
+
The task will create JSON (`fitting/report.json`) and HTML (`fitting/index.html`) reports.
|
156
187
|
|
157
|
-
##
|
188
|
+
## Tests coverage
|
158
189
|
|
159
|
-
|
190
|
+
Only `xs` size is available for tests coverage:
|
160
191
|
|
161
|
-
|
192
|
+
```bash
|
193
|
+
rake fitting:tests_responses[xs]
|
194
|
+
```
|
162
195
|
|
163
196
|
## Config
|
164
197
|
|
165
|
-
You can specify the settings either in a
|
166
|
-
If your project uses several prefixes, for each one you
|
198
|
+
You can specify the settings either in a YAML file `.fitting.yml` or in a config.
|
199
|
+
If your project uses several prefixes, for each one you should create a separate YAML file in the folder `fitting` (`fitting/*.yml`).
|
167
200
|
|
168
|
-
|
201
|
+
All the available config options are described below.
|
169
202
|
|
170
|
-
|
203
|
+
### `apib_path`
|
171
204
|
|
172
|
-
|
205
|
+
Path to API Blueprint v3 documentation.
|
206
|
+
There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
173
207
|
|
174
|
-
|
208
|
+
### `drafter_yaml_path`
|
175
209
|
|
176
|
-
|
210
|
+
Path to API Blueprint v3 documentation, pre-parsed with `drafter` and saved to a YAML file.
|
177
211
|
|
178
|
-
|
212
|
+
### `drafter_4_apib_path`
|
179
213
|
|
180
|
-
|
214
|
+
Path to API Blueprint v4 documentation.
|
215
|
+
There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
181
216
|
|
182
|
-
|
217
|
+
### `drafter_4_yaml_path`
|
183
218
|
|
184
|
-
|
219
|
+
Path to API Blueprint v4 documentation, pre-parsed with `drafter` and saved to a YAML file.
|
220
|
+
|
221
|
+
### `crafter_apib_path`
|
185
222
|
|
186
223
|
Path to API Blueprint v4 documentation.
|
187
224
|
|
188
|
-
### crafter_yaml_path
|
225
|
+
### `crafter_yaml_path`
|
189
226
|
|
190
|
-
Path to API Blueprint v4 documentation pre-parsed with `crafter` and saved to a YAML file.
|
227
|
+
Path to API Blueprint v4 documentation, pre-parsed with `crafter` and saved to a YAML file.
|
191
228
|
|
192
|
-
### tomogram_json_path
|
229
|
+
### `tomogram_json_path`
|
193
230
|
|
194
|
-
Path to Tomogram documentation pre-parsed with [tomograph](https://github.com/funbox/tomograph) and saved to a JSON file.
|
231
|
+
Path to Tomogram documentation, pre-parsed with [tomograph](https://github.com/funbox/tomograph) and saved to a JSON file.
|
195
232
|
|
196
|
-
### strict
|
233
|
+
### `strict`
|
197
234
|
|
198
|
-
Default `false
|
235
|
+
Default: `false`
|
199
236
|
|
200
|
-
|
237
|
+
When `true` all properties are considered to have `"required": true` and all objects are considered to have `"additionalProperties": false`.
|
201
238
|
|
202
|
-
|
239
|
+
### `prefix`
|
203
240
|
|
204
|
-
|
241
|
+
Prefix for API requests. E.g. `'/api'`. Validation will not be performed if the request path does not start with a prefix.
|
205
242
|
|
206
|
-
|
207
|
-
|
208
|
-
|
243
|
+
### `white_list`
|
244
|
+
|
245
|
+
Default: all paths
|
246
|
+
|
247
|
+
This is an array of paths that are mandatory for implementation.
|
248
|
+
The list does not affect the work of the matcher.
|
249
|
+
It's used for the CLI report only.
|
209
250
|
|
210
251
|
```yaml
|
211
252
|
white_list:
|
@@ -220,13 +261,15 @@ white_list:
|
|
220
261
|
/sessions: []
|
221
262
|
```
|
222
263
|
|
223
|
-
Empty array `[]` means all methods.
|
264
|
+
Empty array (`[]`) means all methods.
|
265
|
+
|
266
|
+
### `resource_white_list`
|
224
267
|
|
225
|
-
|
268
|
+
Default: all resources
|
226
269
|
|
227
|
-
|
228
|
-
|
229
|
-
|
270
|
+
This is an array of resources that are mandatory for implementation.
|
271
|
+
The list does not affect the work of the matcher.
|
272
|
+
It's used for the CLI report only.
|
230
273
|
|
231
274
|
```yaml
|
232
275
|
resource_white_list:
|
@@ -240,31 +283,35 @@ resource_white_list:
|
|
240
283
|
/sessions: []
|
241
284
|
```
|
242
285
|
|
243
|
-
Empty array `[]` means all methods.
|
286
|
+
Empty array (`[]`) means all methods.
|
287
|
+
|
288
|
+
### `json_schema_cover`
|
244
289
|
|
245
|
-
|
290
|
+
Default: false
|
246
291
|
|
247
|
-
|
248
|
-
|
292
|
+
JSON-schema covering becomes mandatory.
|
293
|
+
However, if you don't use `Fitting.statistics` you can call `responses.statistics.cover_save`.
|
249
294
|
|
250
|
-
### include_resources
|
295
|
+
### `include_resources`
|
296
|
+
|
297
|
+
Default: all resources (but only when `include_resources` and `include_actions` are not defined)
|
251
298
|
|
252
|
-
Default: all resources if `include_resources` and `include_actions` is not used.
|
253
299
|
This is an array of resources that are mandatory for implementation.
|
254
|
-
|
255
|
-
|
300
|
+
The list does not affect the work of the matcher.
|
301
|
+
It's used for the CLI report only.
|
256
302
|
|
257
303
|
```yaml
|
258
304
|
include_resources:
|
259
305
|
- /sessions
|
260
306
|
```
|
261
307
|
|
262
|
-
### include_actions
|
308
|
+
### `include_actions`
|
309
|
+
|
310
|
+
Default: all paths (but only when `include_resources` and `include_actions` are not defined)
|
263
311
|
|
264
|
-
Default: all paths if `include_resources` and `include_actions` is not used.
|
265
312
|
This is an array of paths that are mandatory for implementation.
|
266
|
-
|
267
|
-
|
313
|
+
The list does not affect the work of the matcher.
|
314
|
+
It's used for the CLI report only.
|
268
315
|
|
269
316
|
```yaml
|
270
317
|
include_actions:
|
@@ -275,9 +322,9 @@ include_actions:
|
|
275
322
|
- GET /users/{id}/employees
|
276
323
|
```
|
277
324
|
|
278
|
-
### ignore_list
|
325
|
+
### `ignore_list`
|
279
326
|
|
280
|
-
You can use ignore list
|
327
|
+
You can use ignore list to omit checks with matchers.
|
281
328
|
|
282
329
|
```yaml
|
283
330
|
ignore_list:
|
@@ -285,12 +332,25 @@ ignore_list:
|
|
285
332
|
- %r{/api/v1/comments}
|
286
333
|
```
|
287
334
|
|
288
|
-
It works only for match_schema
|
335
|
+
It works only for `match_schema` and **not** for `strictly_match_schema`.
|
336
|
+
|
337
|
+
### `prefixes`
|
338
|
+
|
339
|
+
Example:
|
340
|
+
|
341
|
+
```yaml
|
342
|
+
prefixes:
|
343
|
+
- name: /api/v1
|
344
|
+
- name: /api/v2
|
345
|
+
```
|
289
346
|
|
290
347
|
## Contributing
|
291
348
|
|
292
|
-
Bug reports and pull requests are welcome on GitHub at
|
349
|
+
Bug reports and pull requests are welcome on GitHub at [github.com/funbox/fitting](https://github.com/funbox/fitting).
|
350
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
293
351
|
|
294
352
|
## License
|
295
353
|
|
296
354
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
355
|
+
|
356
|
+
[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)
|