fitting 1.6.0 → 1.6.1
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.
- checksums.yaml +4 -4
- data/README.md +26 -28
- data/fitting.gemspec +1 -1
- data/lib/fitting/route.rb +7 -3
- data/lib/fitting/statistics.rb +1 -1
- data/lib/fitting/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4da6330584b695ce8964a021a89fbf7e5d6c73e
|
4
|
+
data.tar.gz: 5972f7305b5eaf446e738d6bf3d68dda0772c804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b06b29a08066358392409e23dd9813d6a8fdaede35aa7b975356064266be5e32d6a0ed3f27931f80c636a884252cc8c972a40b0c1f227804768d5c4a3171b4
|
7
|
+
data.tar.gz: 8200a2a160af99edf0b163157f0db626241361100770e2915cb19f39b622efe43bf8cd26560f00b25b04d6b46e21d1235552543b856296b5e30240a2cf041979
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/funbox/fitting)
|
4
4
|
|
5
|
-
This gem will help
|
6
|
-
To do this, when you run your
|
5
|
+
This gem will help you implement your API in strict accordance to the documentation in [API Bluprint](https://apiblueprint.org/) format.
|
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.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -27,55 +27,59 @@ In your `spec_helper.rb`:
|
|
27
27
|
|
28
28
|
```ruby
|
29
29
|
Fitting.configure do |config|
|
30
|
-
config.apib_path =
|
30
|
+
config.apib_path = '/path/to/doc.apib'
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
34
|
## Example output
|
35
35
|
|
36
|
-
After running tests you will get statistics in the console
|
36
|
+
After running tests you will get statistics in the console:
|
37
37
|
|
38
38
|
```
|
39
39
|
Fully conforming requests:
|
40
40
|
DELETE /api/v1/book ✔ 200 ✔ 201 ✔ 404
|
41
41
|
DELETE /api/v1/book/{id} ✔ 200 ✔ 201 ✔ 404
|
42
42
|
GET /api/v1/book/{id}/seller ✔ 200 ✔ 201 ✔ 404
|
43
|
-
|
43
|
+
|
44
44
|
Partially conforming requests:
|
45
45
|
GET /api/v1/book ✖ 200 ✔ 404
|
46
46
|
POST /api/v1/book ✖ 200 ✔ 201 ✔ 404
|
47
47
|
GET /api/v1/book/{id} ✖ 200 ✔ 404 ✔ 200
|
48
48
|
PATCH /api/v1/book/{id} ✖ 200 ✔ 201 ✔ 404
|
49
|
-
|
49
|
+
|
50
50
|
Non-conforming requests:
|
51
51
|
GET /api/v1/seller ✖ 200 ✖ 201 ✖ 404
|
52
52
|
GET /api/v1/buyer ✖ 200 ✖ 404
|
53
|
-
|
53
|
+
|
54
54
|
API requests with fully implemented responses: 3 (33.33% of 9).
|
55
55
|
API requests with partially implemented responses: 4 (44.44% of 9).
|
56
56
|
API requests with no implemented responses: 2 (22.22% of 9).
|
57
|
-
|
57
|
+
|
58
58
|
API responses conforming to the blueprint: 16 (64.00% of 25).
|
59
59
|
API responses with validation errors or untested: 9 (36.00% of 25).
|
60
60
|
```
|
61
61
|
|
62
62
|
## Matchers
|
63
63
|
|
64
|
-
If you want know
|
64
|
+
If you want to know why you get crosses instead of checkmarks you can use matchers for RSpec.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
config.include Fitting::Matchers, type: :controller
|
68
|
+
```
|
65
69
|
|
66
70
|
### match_response
|
67
71
|
|
68
|
-
Makes a simple validation JSON Schema.
|
72
|
+
Makes a simple validation against JSON Schema.
|
69
73
|
|
70
|
-
```
|
74
|
+
```ruby
|
71
75
|
expect(response).to match_response
|
72
76
|
```
|
73
77
|
|
74
78
|
### strict_match_response
|
75
79
|
|
76
|
-
Makes a strict validation JSON Schema. All properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
|
80
|
+
Makes a strict validation against JSON Schema. All properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
|
77
81
|
|
78
|
-
```
|
82
|
+
```ruby
|
79
83
|
expect(response).to strict_match_response
|
80
84
|
```
|
81
85
|
|
@@ -83,29 +87,29 @@ expect(response).to strict_match_response
|
|
83
87
|
|
84
88
|
### apib_path
|
85
89
|
|
86
|
-
Path
|
90
|
+
Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
87
91
|
|
88
92
|
### drafter_yaml_path
|
89
93
|
|
90
|
-
Path
|
94
|
+
Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
|
91
95
|
|
92
96
|
### necessary_fully_implementation_of_responses
|
93
97
|
|
94
|
-
Default `true`. It returns `exit 1` if not implemented
|
98
|
+
Default `true`. It returns `exit 1` if not all responses are implemented according to the documentation. For this to work, `match_response` (see above) should run.
|
95
99
|
|
96
100
|
### strict
|
97
101
|
|
98
|
-
Default `false`. If `true`
|
102
|
+
Default `false`. If `true` then all properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
|
99
103
|
|
100
104
|
### prefix
|
101
105
|
|
102
|
-
Prefix
|
106
|
+
Prefix of API requests. Example: `'/api'`.
|
103
107
|
|
104
108
|
### white_list
|
105
109
|
|
106
|
-
Default all resources. This is an array of resources that are mandatory for implementation.
|
107
|
-
This list does not affect the work of the
|
108
|
-
This list is only for the report in the console
|
110
|
+
Default: all resources. This is an array of resources that are mandatory for implementation.
|
111
|
+
This list does not affect the work of the matcher.
|
112
|
+
This list is only for the report in the console.
|
109
113
|
|
110
114
|
```ruby
|
111
115
|
config.white_list = {
|
@@ -118,20 +122,14 @@ config.white_list = {
|
|
118
122
|
|
119
123
|
Empty array `[]` means all methods.
|
120
124
|
|
121
|
-
Result be two statistic for two list.
|
122
|
-
|
123
125
|
### create_report_with_name
|
124
126
|
|
125
|
-
|
127
|
+
File name for the report.
|
126
128
|
|
127
129
|
### show_statistics_in_console
|
128
130
|
|
129
131
|
Default `true`.
|
130
132
|
|
131
|
-
## Report
|
132
|
-
|
133
|
-
Autogenerate `report_request_by_response.yaml` and `report_response.yaml reports`.
|
134
|
-
|
135
133
|
## Contributing
|
136
134
|
|
137
135
|
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.
|
data/fitting.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['d.efimov@fun-box.ru']
|
11
11
|
|
12
12
|
spec.summary = 'Validation in the rspec of API Blueprint'
|
13
|
-
spec.description = 'Validation
|
13
|
+
spec.description = 'Validation responses in the rspec with the help of API Blueprint'
|
14
14
|
spec.homepage = 'https://github.com/funbox/fitting'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
data/lib/fitting/route.rb
CHANGED
@@ -5,9 +5,13 @@ require 'fitting/route/responses'
|
|
5
5
|
module Fitting
|
6
6
|
class Route
|
7
7
|
def initialize(all_responses, routes, strict)
|
8
|
-
coverage = Fitting::Route::Coverage.new(all_responses, routes, strict)
|
9
|
-
@requests = Fitting::Route::Requests.new(coverage)
|
10
|
-
@responses = Fitting::Route::Responses.new(routes, coverage)
|
8
|
+
@coverage = Fitting::Route::Coverage.new(all_responses, routes, strict)
|
9
|
+
@requests = Fitting::Route::Requests.new(@coverage)
|
10
|
+
@responses = Fitting::Route::Responses.new(routes, @coverage)
|
11
|
+
end
|
12
|
+
|
13
|
+
def not_coverage?
|
14
|
+
@coverage.not_coverage.present?
|
11
15
|
end
|
12
16
|
|
13
17
|
def statistics
|
data/lib/fitting/statistics.rb
CHANGED
data/lib/fitting/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -212,7 +212,7 @@ dependencies:
|
|
212
212
|
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: 0.43.0
|
215
|
-
description: Validation
|
215
|
+
description: Validation responses in the rspec with the help of API Blueprint
|
216
216
|
email:
|
217
217
|
- d.efimov@fun-box.ru
|
218
218
|
executables: []
|