fitting 2.11.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/.tool-versions +1 -0
  6. data/.travis.yml +1 -1
  7. data/CHANGELOG.md +47 -0
  8. data/README.md +136 -76
  9. data/fitting.gemspec +1 -1
  10. data/lib/fitting.rb +5 -0
  11. data/lib/fitting/cover/json_schema.rb +21 -80
  12. data/lib/fitting/cover/json_schema_enum.rb +20 -70
  13. data/lib/fitting/cover/json_schema_one_of.rb +38 -0
  14. data/lib/fitting/records/spherical/requests.rb +3 -1
  15. data/lib/fitting/records/unit/json_schema.rb +26 -0
  16. data/lib/fitting/report/action.rb +53 -0
  17. data/lib/fitting/report/actions.rb +55 -0
  18. data/lib/fitting/report/combination.rb +37 -0
  19. data/lib/fitting/report/combinations.rb +47 -0
  20. data/lib/fitting/report/console.rb +41 -0
  21. data/lib/fitting/report/prefix.rb +53 -0
  22. data/lib/fitting/report/prefixes.rb +44 -0
  23. data/lib/fitting/report/response.rb +71 -0
  24. data/lib/fitting/report/responses.rb +48 -0
  25. data/lib/fitting/report/test.rb +61 -0
  26. data/lib/fitting/report/tests.rb +62 -0
  27. data/lib/fitting/statistics/cover_error_one_of.rb +27 -0
  28. data/lib/fitting/statistics/list.rb +2 -0
  29. data/lib/fitting/statistics/measurement_cover_one_of.rb +92 -0
  30. data/lib/fitting/statistics/template.rb +5 -0
  31. data/lib/fitting/statistics/template_cover_error_one_of.rb +50 -0
  32. data/lib/fitting/tests.rb +0 -1
  33. data/lib/fitting/version.rb +1 -1
  34. data/lib/tasks/fitting.rake +150 -2
  35. data/lib/templates/bomboniere/.gitignore +21 -0
  36. data/lib/templates/bomboniere/.tool-versions +1 -0
  37. data/lib/templates/bomboniere/README.md +19 -0
  38. data/lib/templates/bomboniere/dist/css/app.62e086ac.css +1 -0
  39. data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
  40. data/lib/templates/bomboniere/dist/favicon.ico +0 -0
  41. data/lib/templates/bomboniere/dist/index.html +1 -0
  42. data/lib/templates/bomboniere/dist/js/app.4356d509.js +2 -0
  43. data/lib/templates/bomboniere/dist/js/app.4356d509.js.map +1 -0
  44. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js +13 -0
  45. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js.map +1 -0
  46. data/lib/templates/bomboniere/package-lock.json +9263 -0
  47. data/lib/templates/bomboniere/package.json +25 -0
  48. data/lib/templates/bomboniere/public/favicon.ico +0 -0
  49. data/lib/templates/bomboniere/public/index.html +17 -0
  50. data/lib/templates/bomboniere/src/App.vue +102 -0
  51. data/lib/templates/bomboniere/src/assets/logo.png +0 -0
  52. data/lib/templates/bomboniere/src/components/HelloWorld.vue +188 -0
  53. data/lib/templates/bomboniere/src/main.js +10 -0
  54. data/lib/templates/bomboniere/src/router/index.js +31 -0
  55. data/lib/templates/bomboniere/src/views/About.vue +5 -0
  56. data/lib/templates/bomboniere/src/views/Action.vue +154 -0
  57. data/lib/templates/bomboniere/src/views/Home.vue +17 -0
  58. data/lib/templates/bomboniere/vue.config.js +3 -0
  59. metadata +47 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9fe2c40a89499b32b2a4989a88cb8d294c420191
4
- data.tar.gz: cd0deaa0b1fb6003bc6c58054def0843fa22e656
2
+ SHA256:
3
+ metadata.gz: 036f174c7154d494520197fefae664cf6086fb47feaad76f091d25f194016ce8
4
+ data.tar.gz: 339e5f12a4a85e86f10bb112bdf23231d9f0af5bbc6a2fba0145f344a37802da
5
5
  SHA512:
6
- metadata.gz: 1e2e177b230a274a1e53d2eb525f6f59f89ffcdcc9ae4392183f0021ae727f3a4d48499dd870bf853ea49a21d7eeec00c9196f1659506348d14dae07287688e3
7
- data.tar.gz: a4ae0ec1d99a3f6b9d9e9fd10bcdeaf592be1335ada092481dece76250da9caa5f4f3cf084d290f792bb16fa897fe361a0967c4c739f918fcedb53a4e8d3bac9
6
+ metadata.gz: dde3886c4f56bcab60b00f91f0a3c129676f430b2c3c5c3687a08fe28c207474e3076d21780e8f9adb2a2c6f6e0bc02f490a4101d77394ed2d92ec5f9687f9cd
7
+ data.tar.gz: f2d6bc93bed0cfe10d0fadb3bb528e837cb4b9867e479991e2f71f772f961113a937c9559903435b55b64d3c2993a275872b804f31fb09c077d252db7d9fb8b2
data/.gitignore CHANGED
@@ -9,4 +9,3 @@
9
9
  /tmp/
10
10
  .idea/
11
11
  .byebug_history
12
- .tool-versions
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.3
3
3
 
4
4
  Metrics/LineLength:
5
5
  Max: 120
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.3.0
@@ -0,0 +1 @@
1
+ ruby 2.3.0
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
3
+ - 2.3
4
4
  before_install: gem install bundler -v 1.12
@@ -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 json-schemas in the documentation and then validates responses with them.
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
- Add this line to your application's Gemfile:
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
- And then execute:
19
+ After that execute:
22
20
 
23
- $ bundle
21
+ ```bash
22
+ $ bundle
23
+ ```
24
24
 
25
- Or install it yourself as:
25
+ Or install the gem by yourself:
26
26
 
27
- $ gem install fitting
27
+ ```bash
28
+ $ gem install fitting
29
+ ```
28
30
 
29
31
  ## Usage
30
32
 
31
- In your `.fitting.yml`:
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
- In your `spec_helper.rb`:
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 ./fitting_tests/ path
47
+ The result files will be created in `./fitting_tests/` folder.
46
48
 
47
- Example:
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
- ## Check documentation cover
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
- ### xs size
97
+ E.g. for `xs` size:
84
98
 
85
- For match routes and valid json-schemas run `rake fitting:documentation_responses[xs]`
99
+ ```bash
100
+ rake fitting:documentation_responses[xs]
101
+ ```
86
102
 
87
- You will get statistics:
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
- ### s size
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
- For details `rake fitting:documentation_responses_error[s]`
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
- ### m size
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
- In addition to the previous comand, you will learn the coverage(enum) json-schemas with task `rake fitting:documentation_responses[m]`
155
- For details `rake fitting:documentation_responses_error[m]`
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
- ## Check tests cover
188
+ ## Tests coverage
158
189
 
159
- ### xs size
190
+ Only `xs` size is available for tests coverage:
160
191
 
161
- `rake fitting:tests_responses[xs]`
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 yaml file `.fitting.yml` or in config.
166
- If your project uses several prefixes, for each one you need to create a separate yaml file in the folder `fitting` (`fitting/*.yml`).
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
- ### apib_path
201
+ All the available config options are described below.
169
202
 
170
- Path to API Blueprint v3 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
203
+ ### `apib_path`
171
204
 
172
- ### drafter_yaml_path
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
- Path to API Blueprint v3 documentation pre-parsed with `drafter` and saved to a YAML file.
208
+ ### `drafter_yaml_path`
175
209
 
176
- ### drafter_4_apib_path
210
+ Path to API Blueprint v3 documentation, pre-parsed with `drafter` and saved to a YAML file.
177
211
 
178
- Path to API Blueprint v4 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
212
+ ### `drafter_4_apib_path`
179
213
 
180
- ### drafter_4_yaml_path
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
- Path to API Blueprint v4 documentation pre-parsed with `drafter` and saved to a YAML file.
217
+ ### `drafter_4_yaml_path`
183
218
 
184
- ### crafter_apib_path
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`. If `true` then all properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
235
+ Default: `false`
199
236
 
200
- ### prefix
237
+ When `true` all properties are considered to have `"required": true` and all objects are considered to have `"additionalProperties": false`.
201
238
 
202
- Prefix of API requests. Example: `'/api'`. Validation will not be performed if the request path does not start with a prefix.
239
+ ### `prefix`
203
240
 
204
- ### white_list
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
- Default: all paths. This is an array of paths that are mandatory for implementation.
207
- This list does not affect the work of the matcher.
208
- This list is only for the report in the console.
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
- ### resource_white_list
268
+ Default: all resources
226
269
 
227
- Default: all resources. This is an array of resources that are mandatory for implementation.
228
- This list does not affect the work of the matcher.
229
- This list is only for the report in the console.
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
- ### json_schema_cover
290
+ Default: false
246
291
 
247
- Default: false. Json-schema covering becomes mandatory.
248
- Or you can call `responses.statistics.cover_save` if you don't use call `Fitting.statistics`.
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
- This list does not affect the work of the matcher.
255
- This list is only for the report in the console.
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
- This list does not affect the work of the matcher.
267
- This list is only for the report in the console.
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 for omit checks with matchers.
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 (NOT FOR strictly_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 https://github.com/funbox/fitting. 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.
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)