openapi_rspec 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8ce3f1674f46c2c7791386f64e694d0170a7693d16b89a5c21923cb23cc58b2
|
4
|
+
data.tar.gz: 615878aa004e98712a802c0dd44ca42465edd5b86c5bd6744cfe1f10dd79c953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d71a291c462a84e94878134ec1e006d0063ee8fb9ef2ba5ece050e821af5b4075d8fcba40670beaa35dfef3cce5d00d369ed12666a0e218e62d8cd98efc82846
|
7
|
+
data.tar.gz: e3a4c671f8ffb61f9e1db4c89c857acf6c700c9f02dca499d2f727eb70c924fab8bbc509bf486e960a02e220a4536ec79d448a6b0772b3492dfc880526c0a0e0
|
@@ -3,18 +3,19 @@ module OpenapiRspec
|
|
3
3
|
def expect_validate_request(code, metadata: {})
|
4
4
|
expect(subject).to validate_request(**request_params(metadata), code: code)
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def request_params(metadata)
|
8
|
-
|
8
|
+
{}.tap do |hash|
|
9
9
|
hash[:method] = defined?(http_method) ? http_method : metadata[:method]
|
10
10
|
hash[:path] = defined?(uri) ? uri : metadata[:uri]
|
11
|
+
hash[:media_type] = openapi_rspec_media_type if defined? openapi_rspec_media_type
|
11
12
|
hash[:params] = path_params(hash[:path])
|
12
13
|
hash[:params].merge!(openapi_rspec_params) if defined? openapi_rspec_params
|
13
14
|
hash[:headers] = openapi_rspec_headers if defined? openapi_rspec_headers
|
14
15
|
hash[:query] = openapi_rspec_query if defined? openapi_rspec_query
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
def path_params(path)
|
19
20
|
path_params = {}
|
20
21
|
path.scan(/\{([^\}]*)\}/).each do |param|
|
@@ -10,39 +10,43 @@ module OpenapiRspec
|
|
10
10
|
def params(&block)
|
11
11
|
let(:openapi_rspec_params, &block)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
def media_type(&block)
|
15
|
+
let(:openapi_rspec_media_type, &block)
|
16
|
+
end
|
17
|
+
|
14
18
|
def headers(&block)
|
15
19
|
let(:openapi_rspec_headers, &block)
|
16
20
|
end
|
17
|
-
|
21
|
+
|
18
22
|
def query(&block)
|
19
23
|
let(:openapi_rspec_query, &block)
|
20
24
|
end
|
21
|
-
|
25
|
+
|
22
26
|
def get(*args, &block)
|
23
27
|
process(:get, *args, &block)
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
def post(*args, &block)
|
27
31
|
process(:post, *args, &block)
|
28
32
|
end
|
29
|
-
|
33
|
+
|
30
34
|
def put(*args, &block)
|
31
35
|
process(:put, *args, &block)
|
32
36
|
end
|
33
|
-
|
37
|
+
|
34
38
|
def delete(*args, &block)
|
35
39
|
process(:delete, *args, &block)
|
36
40
|
end
|
37
|
-
|
41
|
+
|
38
42
|
def head(*args, &block)
|
39
43
|
process(:head, *args, &block)
|
40
44
|
end
|
41
|
-
|
45
|
+
|
42
46
|
def patch(*args, &block)
|
43
47
|
process(:patch, *args, &block)
|
44
48
|
end
|
45
|
-
|
49
|
+
|
46
50
|
def process(method, uri)
|
47
51
|
metadata[:openapi_rspec] = {
|
48
52
|
uri: uri,
|
@@ -9,19 +9,21 @@ module OpenapiRspec
|
|
9
9
|
OpenapiRspec.app
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(path:, method:, code:, params: {}, query: {}, headers: {})
|
12
|
+
def initialize(path:, method:, code:, media_type: "application/json", params: {}, query: {}, headers: {})
|
13
13
|
@path = path
|
14
14
|
@method = method
|
15
15
|
@code = code
|
16
|
+
@media_type = media_type
|
16
17
|
@query = query
|
17
18
|
@headers = headers
|
18
19
|
@params = params
|
19
20
|
end
|
20
21
|
|
21
|
-
attr_reader :method, :path, :code, :query, :headers, :params
|
22
|
+
attr_reader :method, :path, :code, :media_type, :query, :headers, :params
|
22
23
|
|
23
24
|
def matches?(doc)
|
24
|
-
@result = doc.validate_request(path: path, method: method, code: code)
|
25
|
+
@result = doc.validate_request(path: path, method: method, code: code, media_type: media_type)
|
26
|
+
|
25
27
|
return false unless @result.valid?
|
26
28
|
|
27
29
|
headers.each do |key, value|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svyatoslav Kryukov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|