fitting 2.12.0 → 2.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) 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 +48 -0
  8. data/README.md +134 -79
  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 +22 -14
  14. data/lib/fitting/records/spherical/requests.rb +3 -1
  15. data/lib/fitting/report/action.rb +53 -0
  16. data/lib/fitting/report/actions.rb +55 -0
  17. data/lib/fitting/report/combination.rb +37 -0
  18. data/lib/fitting/report/combinations.rb +47 -0
  19. data/lib/fitting/report/console.rb +41 -0
  20. data/lib/fitting/report/prefix.rb +53 -0
  21. data/lib/fitting/report/prefixes.rb +44 -0
  22. data/lib/fitting/report/response.rb +71 -0
  23. data/lib/fitting/report/responses.rb +48 -0
  24. data/lib/fitting/report/test.rb +61 -0
  25. data/lib/fitting/report/tests.rb +62 -0
  26. data/lib/fitting/tests.rb +0 -1
  27. data/lib/fitting/version.rb +1 -1
  28. data/lib/tasks/fitting.rake +128 -0
  29. data/lib/templates/bomboniere/.gitignore +21 -0
  30. data/lib/templates/bomboniere/.tool-versions +1 -0
  31. data/lib/templates/bomboniere/README.md +19 -0
  32. data/lib/templates/bomboniere/dist/css/app.62e086ac.css +1 -0
  33. data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
  34. data/lib/templates/bomboniere/dist/favicon.ico +0 -0
  35. data/lib/templates/bomboniere/dist/index.html +1 -0
  36. data/lib/templates/bomboniere/dist/js/app.4356d509.js +2 -0
  37. data/lib/templates/bomboniere/dist/js/app.4356d509.js.map +1 -0
  38. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js +13 -0
  39. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js.map +1 -0
  40. data/lib/templates/bomboniere/package-lock.json +9271 -0
  41. data/lib/templates/bomboniere/package.json +26 -0
  42. data/lib/templates/bomboniere/public/favicon.ico +0 -0
  43. data/lib/templates/bomboniere/public/index.html +17 -0
  44. data/lib/templates/bomboniere/src/App.vue +102 -0
  45. data/lib/templates/bomboniere/src/assets/logo.png +0 -0
  46. data/lib/templates/bomboniere/src/components/HelloWorld.vue +188 -0
  47. data/lib/templates/bomboniere/src/main.js +10 -0
  48. data/lib/templates/bomboniere/src/router/index.js +31 -0
  49. data/lib/templates/bomboniere/src/views/About.vue +5 -0
  50. data/lib/templates/bomboniere/src/views/Action.vue +154 -0
  51. data/lib/templates/bomboniere/src/views/Home.vue +17 -0
  52. data/lib/templates/bomboniere/vue.config.js +3 -0
  53. metadata +43 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8234af5ba817adef5ce3ff1bf03d4e84c7747169
4
- data.tar.gz: c8a247c8467765022ef0f5f2c7b58b669464cdaf
2
+ SHA256:
3
+ metadata.gz: 442894f4d3f5ebc1db8187887cdbbcd9fd5ca04952e0bccfb2b7c9d77e0e12f9
4
+ data.tar.gz: d521ac6035a27b8adf600e0d53e4e4aa36836c7b4207f1d3479a3e9bb81f16e3
5
5
  SHA512:
6
- metadata.gz: 00863f51cc9692a16ce6cb24aaf83309c4490daac1430081e45081e3c5d24dfe6dba0e17b1df659f3ee84a0b1e49ecaa8c76a1ef5bfc301a70752db6beeafe18
7
- data.tar.gz: fda881919cf0c1bef0ed9228a8d450e866e234da599822f843bed76a146b02ebc143d85d87bda60c294603066a98c4179f9e7dc27162f7b91489eb9d9b90563f
6
+ metadata.gz: e97a22523182921796b087b4ca73b684c9853f8131dcd9102f76cdb3ca940bc60dbb2f17f653a26d05ffca559529a927a21a48de8f6a687a3b5cad3588cd5dd3
7
+ data.tar.gz: 660cbb6a209448f92ebb5463887b406f5021e81886dca21ae5a13d4e35d31f775eea288c65462a9189977d8a9501590ad906c2f5f5320d553258a32960f849c4
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,53 @@
1
1
  # Change log
2
2
 
3
+ ### 2.14.1 - 2020-09-23
4
+
5
+ * fixes
6
+ * fix directory error [#75](https://github.com/funbox/fitting/issues/75)
7
+ * upgrade node-forge [#77](https://github.com/funbox/fitting/issues/77)
8
+
9
+ ### 2.14.0 - 2020-09-18
10
+
11
+ * features
12
+ * save tests for all prefixes [#35](https://github.com/funbox/fitting/issues/35)
13
+ * prefix checking [#37](https://github.com/funbox/fitting/issues/37)
14
+ * html view for prefix checking [#39](https://github.com/funbox/fitting/issues/39)
15
+ * add actions join in new html report [#41](https://github.com/funbox/fitting/issues/41)
16
+ * add responses join in new report [#43](https://github.com/funbox/fitting/issues/43)
17
+ * add combinations join in new report [#47](https://github.com/funbox/fitting/issues/47)
18
+ * add action page [#49](https://github.com/funbox/fitting/issues/49)
19
+ * show more information in new report [#51](https://github.com/funbox/fitting/issues/51)
20
+ * add accordion for prefixes [#55](https://github.com/funbox/fitting/issues/55)
21
+ * move json-schemas to separate files [#57](https://github.com/funbox/fitting/issues/57)
22
+ * add method for tests without actions [#61](https://github.com/funbox/fitting/issues/61)
23
+ * show tests without responses [#63](https://github.com/funbox/fitting/issues/63)
24
+ * add console output for new report [#69](https://github.com/funbox/fitting/issues/69)
25
+ * check test in new console [#71](https://github.com/funbox/fitting/issues/71)
26
+ * fixes
27
+ * fix vulnerability CVE-2020-7660 [#53](https://github.com/funbox/fitting/issues/53)
28
+ * fix cover if response without combinations [#59](https://github.com/funbox/fitting/issues/59)
29
+ * fix cover if combinations without tests [#66](https://github.com/funbox/fitting/issues/66)
30
+ * do not check tests without combinations [#73](https://github.com/funbox/fitting/issues/73)
31
+
32
+ ### 2.13.1 - 2020-04-17
33
+
34
+ * fixes
35
+ * combinations
36
+
37
+ ### 2.13.0 - 2020-02-26
38
+
39
+ * features
40
+ * use request tests
41
+
42
+ * patch
43
+ * improve combination name for enum cover
44
+ * improve combination name for required cover
45
+
46
+ ### 2.12.1 - 2020-02-07
47
+
48
+ * fixes
49
+ * oneOf
50
+
3
51
  ### 2.12.0 - 2019-09-10
4
52
 
5
53
  * 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
80
83
 
81
- ## Check documentation cover
84
+ To match routes and validate JSON-schemas run:
82
85
 
83
- ### xs size
86
+ ```bash
87
+ rake fitting:documentation_responses[report_size]
88
+ ```
84
89
 
85
- For match routes and valid json-schemas run `rake fitting:documentation_responses[xs]`
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.
86
96
 
87
- You will get statistics:
97
+ E.g. for `xs` size:
88
98
 
99
+ ```bash
100
+ rake fitting:documentation_responses[xs]
89
101
  ```
102
+
103
+ **Note**: In zsh you should add quotes around the task:
104
+
105
+ ```bash
106
+ rake 'fitting:documentation_responses[xs]'
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
140
+ `s` size:
114
141
 
115
- In addition to the previous comand, you will learn the coverage(required) json-schemas with task `rake fitting:documentation_responses[s]`
116
-
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,68 +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
153
178
 
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]`
179
+ This report will be available and properly documented in the next major update, but you already can try it by running:
156
180
 
157
- ### l size
181
+ ```bash
182
+ bundle e rake fitting:report
183
+ ```
158
184
 
159
- In addition to the previous comand, you will learn the coverage(oneOf) json-schemas with task `rake fitting:documentation_responses[l]`
160
- For details `rake fitting:documentation_responses_error[l]`
185
+ Using this you can document API prefixes.
186
+ The task will create JSON (`fitting/report.json`) and HTML (`fitting/index.html`) reports.
161
187
 
162
- ## Check tests cover
188
+ ## Tests coverage
163
189
 
164
- ### xs size
190
+ Only `xs` size is available for tests coverage:
165
191
 
166
- `rake fitting:tests_responses[xs]`
192
+ ```bash
193
+ rake fitting:tests_responses[xs]
194
+ ```
167
195
 
168
196
  ## Config
169
197
 
170
- You can specify the settings either in a yaml file `.fitting.yml` or in config.
171
- 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`).
200
+
201
+ All the available config options are described below.
172
202
 
173
- ### apib_path
203
+ ### `apib_path`
174
204
 
175
- Path to API Blueprint v3 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
205
+ Path to API Blueprint v3 documentation.
206
+ There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
176
207
 
177
- ### drafter_yaml_path
208
+ ### `drafter_yaml_path`
178
209
 
179
- Path to API Blueprint v3 documentation pre-parsed with `drafter` and saved to a YAML file.
210
+ Path to API Blueprint v3 documentation, pre-parsed with `drafter` and saved to a YAML file.
180
211
 
181
- ### drafter_4_apib_path
212
+ ### `drafter_4_apib_path`
182
213
 
183
- Path to API Blueprint v4 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
214
+ Path to API Blueprint v4 documentation.
215
+ There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
184
216
 
185
- ### drafter_4_yaml_path
217
+ ### `drafter_4_yaml_path`
186
218
 
187
- Path to API Blueprint v4 documentation pre-parsed with `drafter` and saved to a YAML file.
219
+ Path to API Blueprint v4 documentation, pre-parsed with `drafter` and saved to a YAML file.
188
220
 
189
- ### crafter_apib_path
221
+ ### `crafter_apib_path`
190
222
 
191
223
  Path to API Blueprint v4 documentation.
192
224
 
193
- ### crafter_yaml_path
225
+ ### `crafter_yaml_path`
194
226
 
195
- 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.
196
228
 
197
- ### tomogram_json_path
229
+ ### `tomogram_json_path`
198
230
 
199
- 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.
200
232
 
201
- ### strict
233
+ ### `strict`
202
234
 
203
- Default `false`. If `true` then all properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
235
+ Default: `false`
204
236
 
205
- ### prefix
237
+ When `true` all properties are considered to have `"required": true` and all objects are considered to have `"additionalProperties": false`.
206
238
 
207
- Prefix of API requests. Example: `'/api'`. Validation will not be performed if the request path does not start with a prefix.
239
+ ### `prefix`
208
240
 
209
- ### 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.
210
242
 
211
- Default: all paths. This is an array of paths that are mandatory for implementation.
212
- This list does not affect the work of the matcher.
213
- 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.
214
250
 
215
251
  ```yaml
216
252
  white_list:
@@ -225,13 +261,15 @@ white_list:
225
261
  /sessions: []
226
262
  ```
227
263
 
228
- Empty array `[]` means all methods.
264
+ Empty array (`[]`) means all methods.
229
265
 
230
- ### resource_white_list
266
+ ### `resource_white_list`
231
267
 
232
- Default: all resources. This is an array of resources that are mandatory for implementation.
233
- This list does not affect the work of the matcher.
234
- This list is only for the report in the console.
268
+ Default: all resources
269
+
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.
235
273
 
236
274
  ```yaml
237
275
  resource_white_list:
@@ -245,31 +283,35 @@ resource_white_list:
245
283
  /sessions: []
246
284
  ```
247
285
 
248
- Empty array `[]` means all methods.
286
+ Empty array (`[]`) means all methods.
287
+
288
+ ### `json_schema_cover`
289
+
290
+ Default: false
249
291
 
250
- ### json_schema_cover
292
+ JSON-schema covering becomes mandatory.
293
+ However, if you don't use `Fitting.statistics` you can call `responses.statistics.cover_save`.
251
294
 
252
- Default: false. Json-schema covering becomes mandatory.
253
- Or you can call `responses.statistics.cover_save` if you don't use call `Fitting.statistics`.
295
+ ### `include_resources`
254
296
 
255
- ### include_resources
297
+ Default: all resources (but only when `include_resources` and `include_actions` are not defined)
256
298
 
257
- Default: all resources if `include_resources` and `include_actions` is not used.
258
299
  This is an array of resources that are mandatory for implementation.
259
- This list does not affect the work of the matcher.
260
- 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.
261
302
 
262
303
  ```yaml
263
304
  include_resources:
264
305
  - /sessions
265
306
  ```
266
307
 
267
- ### include_actions
308
+ ### `include_actions`
309
+
310
+ Default: all paths (but only when `include_resources` and `include_actions` are not defined)
268
311
 
269
- Default: all paths if `include_resources` and `include_actions` is not used.
270
312
  This is an array of paths that are mandatory for implementation.
271
- This list does not affect the work of the matcher.
272
- 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.
273
315
 
274
316
  ```yaml
275
317
  include_actions:
@@ -280,9 +322,9 @@ include_actions:
280
322
  - GET /users/{id}/employees
281
323
  ```
282
324
 
283
- ### ignore_list
325
+ ### `ignore_list`
284
326
 
285
- You can use ignore list for omit checks with matchers.
327
+ You can use ignore list to omit checks with matchers.
286
328
 
287
329
  ```yaml
288
330
  ignore_list:
@@ -290,12 +332,25 @@ ignore_list:
290
332
  - %r{/api/v1/comments}
291
333
  ```
292
334
 
293
- 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
+ ```
294
346
 
295
347
  ## Contributing
296
348
 
297
- 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.
298
351
 
299
352
  ## License
300
353
 
301
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)