fitting 2.12.1 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +33 -0
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/.tool-versions +1 -1
  6. data/CHANGELOG.md +54 -0
  7. data/README.md +127 -85
  8. data/fitting.gemspec +3 -3
  9. data/lib/fitting.rb +5 -0
  10. data/lib/fitting/cover/json_schema.rb +21 -80
  11. data/lib/fitting/cover/json_schema_enum.rb +20 -70
  12. data/lib/fitting/cover/json_schema_one_of.rb +7 -5
  13. data/lib/fitting/records/spherical/requests.rb +3 -1
  14. data/lib/fitting/report/action.rb +53 -0
  15. data/lib/fitting/report/actions.rb +55 -0
  16. data/lib/fitting/report/combination.rb +37 -0
  17. data/lib/fitting/report/combinations.rb +47 -0
  18. data/lib/fitting/report/console.rb +41 -0
  19. data/lib/fitting/report/prefix.rb +53 -0
  20. data/lib/fitting/report/prefixes.rb +44 -0
  21. data/lib/fitting/report/response.rb +71 -0
  22. data/lib/fitting/report/responses.rb +48 -0
  23. data/lib/fitting/report/test.rb +75 -0
  24. data/lib/fitting/report/tests.rb +69 -0
  25. data/lib/fitting/tests.rb +0 -1
  26. data/lib/fitting/version.rb +1 -1
  27. data/lib/tasks/fitting.rake +130 -0
  28. data/lib/templates/bomboniere/.gitignore +21 -0
  29. data/lib/templates/bomboniere/.tool-versions +1 -0
  30. data/lib/templates/bomboniere/README.md +19 -0
  31. data/lib/templates/bomboniere/dist/css/app.aa2bcd8a.css +1 -0
  32. data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
  33. data/lib/templates/bomboniere/dist/favicon.ico +0 -0
  34. data/lib/templates/bomboniere/dist/index.html +1 -0
  35. data/lib/templates/bomboniere/dist/js/app.e5f1a5ec.js +2 -0
  36. data/lib/templates/bomboniere/dist/js/app.e5f1a5ec.js.map +1 -0
  37. data/lib/templates/bomboniere/dist/js/chunk-vendors.0f99b670.js +13 -0
  38. data/lib/templates/bomboniere/dist/js/chunk-vendors.0f99b670.js.map +1 -0
  39. data/lib/templates/bomboniere/package-lock.json +9271 -0
  40. data/lib/templates/bomboniere/package.json +26 -0
  41. data/lib/templates/bomboniere/public/favicon.ico +0 -0
  42. data/lib/templates/bomboniere/public/index.html +17 -0
  43. data/lib/templates/bomboniere/src/App.vue +102 -0
  44. data/lib/templates/bomboniere/src/assets/logo.png +0 -0
  45. data/lib/templates/bomboniere/src/components/HelloWorld.vue +201 -0
  46. data/lib/templates/bomboniere/src/main.js +10 -0
  47. data/lib/templates/bomboniere/src/router/index.js +31 -0
  48. data/lib/templates/bomboniere/src/views/About.vue +5 -0
  49. data/lib/templates/bomboniere/src/views/Action.vue +173 -0
  50. data/lib/templates/bomboniere/src/views/Home.vue +17 -0
  51. data/lib/templates/bomboniere/vue.config.js +3 -0
  52. metadata +63 -29
  53. data/.travis.yml +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1415f580792a267f0db27df63a8ef8334d0cd0cc
4
- data.tar.gz: 4e5868e53b370121ab7cfad0e1762d014b4f310d
2
+ SHA256:
3
+ metadata.gz: d604ca859d26a71406a404ad3fd2ea7d232fa670ee1f930ada129df6fe55f15a
4
+ data.tar.gz: 919ece6a20bdf078459ef5b42351687ddbabb01296364ba52cf4f5e669e36d7d
5
5
  SHA512:
6
- metadata.gz: f93db3c0f9c83d2ec34b84ab4d3e91e8b5d06ba988bc5f4d40eb9c2e63664a30589857909c054e4d19b3099ca223403df2cd8026856a25360dae4ab050cf4dce
7
- data.tar.gz: 81ce958a9daed16da84fea079964caf4b7e396bb473a5d89f856f6ff9a453e398b742aedd667a1dbaebb56a71347b3056d3b61f4b188b32615e1050dfb75e3c3
6
+ metadata.gz: '0810933b01cb101b7cee10d06e522a29e746139181ccd7c948f6af3b6aa0dcf082856db941c371b1e1945839b5a7ddff537fc2656025bf905485d06ed61685bd'
7
+ data.tar.gz: c08f43a84f31a7d029c0c72f4667e95c9e9769a92a3bb243a4a6de7af8da2e493bd63716794ee24f04eb7bd31dff43a71bb2ebf67ec9078685fb08dffd885195
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -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.6.1
@@ -1 +1 @@
1
- ruby 2.2.0
1
+ ruby 2.6.1
@@ -1,5 +1,59 @@
1
1
  # Change log
2
2
 
3
+ ### 2.15.0 - 2020-10-12
4
+
5
+ * features
6
+ * color for bad response [#79](https://github.com/funbox/fitting/issues/79)
7
+ * show test details [#81](https://github.com/funbox/fitting/issues/81)
8
+ * patch
9
+ * update ruby [#83](https://github.com/funbox/fitting/issues/83)
10
+ * update bundler [#84](https://github.com/funbox/fitting/issues/84)
11
+ * update tomograph [#85](https://github.com/funbox/fitting/issues/85)
12
+ * use github actions for CI instead of Travis [#30](https://github.com/funbox/fitting/issues/30)
13
+
14
+ ### 2.14.1 - 2020-09-23
15
+
16
+ * fixes
17
+ * fix directory error [#75](https://github.com/funbox/fitting/issues/75)
18
+ * upgrade node-forge [#77](https://github.com/funbox/fitting/issues/77)
19
+
20
+ ### 2.14.0 - 2020-09-18
21
+
22
+ * features
23
+ * save tests for all prefixes [#35](https://github.com/funbox/fitting/issues/35)
24
+ * prefix checking [#37](https://github.com/funbox/fitting/issues/37)
25
+ * html view for prefix checking [#39](https://github.com/funbox/fitting/issues/39)
26
+ * add actions join in new html report [#41](https://github.com/funbox/fitting/issues/41)
27
+ * add responses join in new report [#43](https://github.com/funbox/fitting/issues/43)
28
+ * add combinations join in new report [#47](https://github.com/funbox/fitting/issues/47)
29
+ * add action page [#49](https://github.com/funbox/fitting/issues/49)
30
+ * show more information in new report [#51](https://github.com/funbox/fitting/issues/51)
31
+ * add accordion for prefixes [#55](https://github.com/funbox/fitting/issues/55)
32
+ * move json-schemas to separate files [#57](https://github.com/funbox/fitting/issues/57)
33
+ * add method for tests without actions [#61](https://github.com/funbox/fitting/issues/61)
34
+ * show tests without responses [#63](https://github.com/funbox/fitting/issues/63)
35
+ * add console output for new report [#69](https://github.com/funbox/fitting/issues/69)
36
+ * check test in new console [#71](https://github.com/funbox/fitting/issues/71)
37
+ * fixes
38
+ * fix vulnerability CVE-2020-7660 [#53](https://github.com/funbox/fitting/issues/53)
39
+ * fix cover if response without combinations [#59](https://github.com/funbox/fitting/issues/59)
40
+ * fix cover if combinations without tests [#66](https://github.com/funbox/fitting/issues/66)
41
+ * do not check tests without combinations [#73](https://github.com/funbox/fitting/issues/73)
42
+
43
+ ### 2.13.1 - 2020-04-17
44
+
45
+ * fixes
46
+ * combinations
47
+
48
+ ### 2.13.0 - 2020-02-26
49
+
50
+ * features
51
+ * use request tests
52
+
53
+ * patch
54
+ * improve combination name for enum cover
55
+ * improve combination name for required cover
56
+
3
57
  ### 2.12.1 - 2020-02-07
4
58
 
5
59
  * fixes
data/README.md CHANGED
@@ -1,42 +1,41 @@
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
- [![Build Status](https://travis-ci.org/funbox/fitting.svg?branch=master)](https://travis-ci.org/funbox/fitting)
9
4
 
10
5
  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.
6
+ 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
7
 
13
8
  ## Installation
14
9
 
15
10
  First you need to install [drafter](https://github.com/apiaryio/drafter).
16
11
 
17
- Second add this line to your application's Gemfile:
12
+ Then add this line to your application's Gemfile:
18
13
 
19
14
  ```ruby
20
15
  gem 'fitting'
21
16
  ```
22
17
 
23
- And then execute:
18
+ After that execute:
24
19
 
25
- $ bundle
20
+ ```bash
21
+ $ bundle
22
+ ```
26
23
 
27
- Or install it yourself as:
24
+ Or install the gem by yourself:
28
25
 
29
- $ gem install fitting
26
+ ```bash
27
+ $ gem install fitting
28
+ ```
30
29
 
31
30
  ## Usage
32
31
 
33
- In your `.fitting.yml`:
32
+ Add this to your `.fitting.yml`:
34
33
 
35
34
  ```yaml
36
35
  apib_path: /path/to/doc.apib
37
36
  ```
38
37
 
39
- In your `spec_helper.rb`:
38
+ And this to your `spec_helper.rb`:
40
39
 
41
40
  ```ruby
42
41
  require 'fitting'
@@ -44,11 +43,11 @@ require 'fitting'
44
43
  Fitting.save_test_data
45
44
  ```
46
45
 
47
- The files will be created in ./fitting_tests/ path
46
+ The result files will be created in `./fitting_tests/` folder.
48
47
 
49
- Example:
48
+ Output example:
50
49
 
51
- ```
50
+ ```json
52
51
  [
53
52
  {
54
53
  "method": "GET",
@@ -75,30 +74,45 @@ Example:
75
74
  },
76
75
  "title": "/spec/controllers/api/v1/books_controller_spec.rb:22",
77
76
  "group": "/spec/controllers/api/v1/books_controller_spec.rb"
78
- },
79
- ...
77
+ }
78
+ ]
80
79
  ```
81
80
 
81
+ ## Documentation coverage
82
+
83
+ To match routes and validate JSON-schemas run:
82
84
 
83
- ## Check documentation cover
85
+ ```bash
86
+ rake fitting:documentation_responses[report_size]
87
+ ```
84
88
 
85
- ### xs size
89
+ There are four types (or `report_size`) of reports available:
90
+
91
+ - `xs` — the smallest report;
92
+ - `s` — includes coverage for `required` fields;
93
+ - `m` — includes coverage for `required` and `enum` fields;
94
+ - `l` — includes coverage for `required`, `enum` and `oneOf` fields.
86
95
 
87
- For match routes and valid json-schemas run
96
+ E.g. for `xs` size:
88
97
 
89
- for bash
90
- ```
98
+ ```bash
91
99
  rake fitting:documentation_responses[xs]
92
100
  ```
93
101
 
94
- for zsh
95
- ```
102
+ **Note**: In zsh you should add quotes around the task:
103
+
104
+ ```bash
96
105
  rake 'fitting:documentation_responses[xs]'
97
106
  ```
98
107
 
99
- You will get statistics:
108
+ Also you can use `documentation_responses_error` to get more detailed errors description.
109
+ Check the examples below.
100
110
 
101
- ```
111
+ ### Examples
112
+
113
+ `xs` size:
114
+
115
+ ```text
102
116
  Fully conforming requests:
103
117
  DELETE /api/v1/book ✔ 200 ✔ 201 ✔ 404
104
118
  DELETE /api/v1/book/{id} ✔ 200 ✔ 201 ✔ 404
@@ -122,11 +136,9 @@ API responses conforming to the blueprint: 16 (64.00% of 25).
122
136
  API responses with validation errors or untested: 9 (36.00% of 25).
123
137
  ```
124
138
 
125
- ### s size
126
-
127
- In addition to the previous comand, you will learn the coverage(required) json-schemas with task `rake fitting:documentation_responses[s]`
139
+ `s` size:
128
140
 
129
- ```
141
+ ```text
130
142
  Fully conforming requests:
131
143
  DELETE /api/v1/book 100% 200 100% 201 100% 404
132
144
  DELETE /api/v1/book/{id} 100% 200 100% 201 100% 404
@@ -150,7 +162,7 @@ API responses conforming to the blueprint: 16 (64.00% of 25).
150
162
  API responses with validation errors or untested: 9 (36.00% of 25).
151
163
  ```
152
164
 
153
- For details `rake fitting:documentation_responses_error[s]`
165
+ `documentation_responses_error[s]` example:
154
166
 
155
167
  ```
156
168
  request method: GET
@@ -161,68 +173,79 @@ combination: ["required", "pages"]
161
173
  new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
162
174
  ```
163
175
 
164
- ### m size
176
+ ### Experimental report
165
177
 
166
- In addition to the previous comand, you will learn the coverage(enum) json-schemas with task `rake fitting:documentation_responses[m]`
167
- For details `rake fitting:documentation_responses_error[m]`
178
+ This report will be available and properly documented in the next major update, but you already can try it by running:
168
179
 
169
- ### l size
180
+ ```bash
181
+ bundle e rake fitting:report
182
+ ```
170
183
 
171
- In addition to the previous comand, you will learn the coverage(oneOf) json-schemas with task `rake fitting:documentation_responses[l]`
172
- For details `rake fitting:documentation_responses_error[l]`
184
+ Using this you can document API prefixes.
185
+ The task will create JSON (`fitting/report.json`) and HTML (`fitting/index.html`) reports.
173
186
 
174
- ## Check tests cover
187
+ ## Tests coverage
175
188
 
176
- ### xs size
189
+ Only `xs` size is available for tests coverage:
177
190
 
178
- `rake fitting:tests_responses[xs]`
191
+ ```bash
192
+ rake fitting:tests_responses[xs]
193
+ ```
179
194
 
180
195
  ## Config
181
196
 
182
- You can specify the settings either in a yaml file `.fitting.yml` or in config.
183
- If your project uses several prefixes, for each one you need to create a separate yaml file in the folder `fitting` (`fitting/*.yml`).
197
+ You can specify the settings either in a YAML file `.fitting.yml` or in a config.
198
+ If your project uses several prefixes, for each one you should create a separate YAML file in the folder `fitting` (`fitting/*.yml`).
199
+
200
+ All the available config options are described below.
184
201
 
185
- ### apib_path
202
+ ### `apib_path`
186
203
 
187
- Path to API Blueprint v3 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
204
+ Path to API Blueprint v3 documentation.
205
+ There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
188
206
 
189
- ### drafter_yaml_path
207
+ ### `drafter_yaml_path`
190
208
 
191
- Path to API Blueprint v3 documentation pre-parsed with `drafter` and saved to a YAML file.
209
+ Path to API Blueprint v3 documentation, pre-parsed with `drafter` and saved to a YAML file.
192
210
 
193
- ### drafter_4_apib_path
211
+ ### `drafter_4_apib_path`
194
212
 
195
- Path to API Blueprint v4 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
213
+ Path to API Blueprint v4 documentation.
214
+ There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
196
215
 
197
- ### drafter_4_yaml_path
216
+ ### `drafter_4_yaml_path`
198
217
 
199
- Path to API Blueprint v4 documentation pre-parsed with `drafter` and saved to a YAML file.
218
+ Path to API Blueprint v4 documentation, pre-parsed with `drafter` and saved to a YAML file.
200
219
 
201
- ### crafter_apib_path
220
+ ### `crafter_apib_path`
202
221
 
203
222
  Path to API Blueprint v4 documentation.
204
223
 
205
- ### crafter_yaml_path
224
+ ### `crafter_yaml_path`
206
225
 
207
- Path to API Blueprint v4 documentation pre-parsed with `crafter` and saved to a YAML file.
226
+ Path to API Blueprint v4 documentation, pre-parsed with `crafter` and saved to a YAML file.
208
227
 
209
- ### tomogram_json_path
228
+ ### `tomogram_json_path`
210
229
 
211
- Path to Tomogram documentation pre-parsed with [tomograph](https://github.com/funbox/tomograph) and saved to a JSON file.
230
+ Path to Tomogram documentation, pre-parsed with [tomograph](https://github.com/funbox/tomograph) and saved to a JSON file.
212
231
 
213
- ### strict
232
+ ### `strict`
214
233
 
215
- Default `false`. If `true` then all properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
234
+ Default: `false`
216
235
 
217
- ### prefix
236
+ When `true` all properties are considered to have `"required": true` and all objects are considered to have `"additionalProperties": false`.
218
237
 
219
- Prefix of API requests. Example: `'/api'`. Validation will not be performed if the request path does not start with a prefix.
238
+ ### `prefix`
220
239
 
221
- ### white_list
240
+ Prefix for API requests. E.g. `'/api'`. Validation will not be performed if the request path does not start with a prefix.
222
241
 
223
- Default: all paths. This is an array of paths that are mandatory for implementation.
224
- This list does not affect the work of the matcher.
225
- This list is only for the report in the console.
242
+ ### `white_list`
243
+
244
+ Default: all paths
245
+
246
+ This is an array of paths that are mandatory for implementation.
247
+ The list does not affect the work of the matcher.
248
+ It's used for the CLI report only.
226
249
 
227
250
  ```yaml
228
251
  white_list:
@@ -237,13 +260,15 @@ white_list:
237
260
  /sessions: []
238
261
  ```
239
262
 
240
- Empty array `[]` means all methods.
263
+ Empty array (`[]`) means all methods.
241
264
 
242
- ### resource_white_list
265
+ ### `resource_white_list`
243
266
 
244
- Default: all resources. This is an array of resources that are mandatory for implementation.
245
- This list does not affect the work of the matcher.
246
- This list is only for the report in the console.
267
+ Default: all resources
268
+
269
+ This is an array of resources that are mandatory for implementation.
270
+ The list does not affect the work of the matcher.
271
+ It's used for the CLI report only.
247
272
 
248
273
  ```yaml
249
274
  resource_white_list:
@@ -257,31 +282,35 @@ resource_white_list:
257
282
  /sessions: []
258
283
  ```
259
284
 
260
- Empty array `[]` means all methods.
285
+ Empty array (`[]`) means all methods.
286
+
287
+ ### `json_schema_cover`
288
+
289
+ Default: false
261
290
 
262
- ### json_schema_cover
291
+ JSON-schema covering becomes mandatory.
292
+ However, if you don't use `Fitting.statistics` you can call `responses.statistics.cover_save`.
263
293
 
264
- Default: false. Json-schema covering becomes mandatory.
265
- Or you can call `responses.statistics.cover_save` if you don't use call `Fitting.statistics`.
294
+ ### `include_resources`
266
295
 
267
- ### include_resources
296
+ Default: all resources (but only when `include_resources` and `include_actions` are not defined)
268
297
 
269
- Default: all resources if `include_resources` and `include_actions` is not used.
270
298
  This is an array of resources 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.
299
+ The list does not affect the work of the matcher.
300
+ It's used for the CLI report only.
273
301
 
274
302
  ```yaml
275
303
  include_resources:
276
304
  - /sessions
277
305
  ```
278
306
 
279
- ### include_actions
307
+ ### `include_actions`
308
+
309
+ Default: all paths (but only when `include_resources` and `include_actions` are not defined)
280
310
 
281
- Default: all paths if `include_resources` and `include_actions` is not used.
282
311
  This is an array of paths that are mandatory for implementation.
283
- This list does not affect the work of the matcher.
284
- This list is only for the report in the console.
312
+ The list does not affect the work of the matcher.
313
+ It's used for the CLI report only.
285
314
 
286
315
  ```yaml
287
316
  include_actions:
@@ -292,9 +321,9 @@ include_actions:
292
321
  - GET /users/{id}/employees
293
322
  ```
294
323
 
295
- ### ignore_list
324
+ ### `ignore_list`
296
325
 
297
- You can use ignore list for omit checks with matchers.
326
+ You can use ignore list to omit checks with matchers.
298
327
 
299
328
  ```yaml
300
329
  ignore_list:
@@ -302,12 +331,25 @@ ignore_list:
302
331
  - %r{/api/v1/comments}
303
332
  ```
304
333
 
305
- It works only for match_schema (NOT FOR strictly_match_schema)
334
+ It works only for `match_schema` and **not** for `strictly_match_schema`.
335
+
336
+ ### `prefixes`
337
+
338
+ Example:
339
+
340
+ ```yaml
341
+ prefixes:
342
+ - name: /api/v1
343
+ - name: /api/v2
344
+ ```
306
345
 
307
346
  ## Contributing
308
347
 
309
- 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.
348
+ Bug reports and pull requests are welcome on GitHub at [github.com/funbox/fitting](https://github.com/funbox/fitting).
349
+ 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.
310
350
 
311
351
  ## License
312
352
 
313
353
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
354
+
355
+ [![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)