openapi_rspec 0.5 → 0.6.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.
- checksums.yaml +4 -4
- data/README.md +3 -6
- data/lib/openapi_rspec/helpers.rb +4 -8
- data/lib/openapi_rspec/module_helpers.rb +1 -1
- data/lib/openapi_rspec/request_validator.rb +14 -13
- data/lib/openapi_rspec/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed454989937d48a4eeef30f34682c4bff0f7e2a40da349eea0eeb8b5a19afb8d
|
4
|
+
data.tar.gz: 4df1828cf06d45281a58b9f3f90c2a8f8d89ca1271303611087e0c90d17d5d2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667444e7e303fbb92082a8c1a1dd796633cafaf532bdfdecae27521c1c5f3e2b70a70816e63c460ec75f414a9a869b834d1864829bd6958e34d3e1f9885e8765
|
7
|
+
data.tar.gz: 3f4328e0214bf15036c8f628bc034dadf497fab685737122cb6f5e80330024ca8328baa832b8b91716a5c80ba0da83c974ae47a2c6fe2c17b95578e7d893e6f3
|
data/README.md
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/openapi_rspec
|
2
|
-
[
|
3
|
-
[codeclimate]: https://codeclimate.com/github/medsolutions/openapi_rspec
|
2
|
+
[codeclimate]: https://codeclimate.com/github/skryukov/openapi_rspec
|
4
3
|
|
5
4
|
# openapi_rspec
|
6
5
|
[][gem]
|
7
|
-
[][codeclimate]
|
9
|
-
[][codeclimate]
|
6
|
+
[](https://github.com/skryukov/openapi_rspec/actions)
|
10
7
|
[](https://github.com/testdouble/standard)
|
11
8
|
|
12
9
|
Test your API against OpenApi v3 documentation
|
@@ -266,7 +263,7 @@ This will raise an error if any of the documented paths are not validated.
|
|
266
263
|
|
267
264
|
## Contributing
|
268
265
|
|
269
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
266
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/skryukov/openapi_rspec.
|
270
267
|
|
271
268
|
## License
|
272
269
|
|
@@ -5,25 +5,21 @@ module OpenapiRspec
|
|
5
5
|
def request_params(metadata)
|
6
6
|
path = defined?(uri) ? uri : metadata[:uri]
|
7
7
|
method = defined?(http_method) ? http_method : metadata[:method]
|
8
|
-
params = if openapi_rspec_params.is_a?(Hash)
|
9
|
-
path_params(path).merge!(openapi_rspec_params)
|
10
|
-
else
|
11
|
-
openapi_rspec_params
|
12
|
-
end
|
13
8
|
|
14
9
|
{
|
15
10
|
method: method,
|
16
11
|
path: path,
|
17
|
-
params:
|
12
|
+
params: openapi_rspec_params,
|
13
|
+
path_params: path_params(path),
|
18
14
|
headers: openapi_rspec_headers,
|
19
15
|
query: openapi_rspec_query,
|
20
|
-
media_type: openapi_rspec_media_type
|
16
|
+
media_type: openapi_rspec_media_type
|
21
17
|
}
|
22
18
|
end
|
23
19
|
|
24
20
|
def path_params(path)
|
25
21
|
path_params = {}
|
26
|
-
path.scan(/\{([
|
22
|
+
path.scan(/\{([^}]*)\}/).each do |param|
|
27
23
|
key = param.first.to_sym
|
28
24
|
path_params[key] = public_send(key) if respond_to?(key)
|
29
25
|
end
|
@@ -7,7 +7,7 @@ module OpenapiRspec
|
|
7
7
|
metadata = example.metadata[:openapi_rspec]
|
8
8
|
validator = RequestValidator.new(**request_params(metadata), code: code)
|
9
9
|
expect(subject).to validator
|
10
|
-
instance_exec validator, &block if
|
10
|
+
instance_exec validator, &block if block
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -13,6 +13,7 @@ module OpenapiRspec
|
|
13
13
|
option :method
|
14
14
|
option :code
|
15
15
|
option :media_type
|
16
|
+
option :path_params
|
16
17
|
option :params
|
17
18
|
option :query
|
18
19
|
option :headers
|
@@ -46,31 +47,31 @@ module OpenapiRspec
|
|
46
47
|
|
47
48
|
private
|
48
49
|
|
50
|
+
def perform_request(doc)
|
51
|
+
headers.each do |key, value|
|
52
|
+
header key, value
|
53
|
+
end
|
54
|
+
request(request_uri(doc), method: method, **request_params)
|
55
|
+
@response = last_response
|
56
|
+
end
|
57
|
+
|
49
58
|
def request_uri(doc)
|
50
|
-
path.scan(/\{([
|
59
|
+
path.scan(/\{([^}]*)\}/).each do |param|
|
51
60
|
key = param.first.to_sym
|
52
|
-
if
|
53
|
-
@path = path.gsub "{#{key}}",
|
61
|
+
if path_params && path_params[key]
|
62
|
+
@path = path.gsub "{#{key}}", path_params[key].to_s
|
54
63
|
else
|
55
|
-
raise URI::InvalidURIError, "No substitution data found for {#{key}}"\
|
64
|
+
raise URI::InvalidURIError, "No substitution data found for {#{key}}" \
|
56
65
|
" to test the path #{path}."
|
57
66
|
end
|
58
67
|
end
|
59
68
|
"#{doc.api_base_path}#{path}?#{URI.encode_www_form(query)}"
|
60
69
|
end
|
61
70
|
|
62
|
-
def perform_request(doc)
|
63
|
-
headers.each do |key, value|
|
64
|
-
header key, value
|
65
|
-
end
|
66
|
-
request(request_uri(doc), method: method, **request_params)
|
67
|
-
@response = last_response
|
68
|
-
end
|
69
|
-
|
70
71
|
def request_params
|
71
72
|
{
|
72
73
|
headers: headers,
|
73
|
-
params: params
|
74
|
+
params: params
|
74
75
|
}
|
75
76
|
end
|
76
77
|
end
|
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:
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svyatoslav Kryukov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.3.7
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Test your API against OpenApi v3 documentation
|