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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 748ba53aceac0ac02c274be192c1fadb895df66212e38da8bf9f88f80943f504
4
- data.tar.gz: d2ab4b53ae116da4daf0bdaec48e2c8ff4d54b8ff98e1e4dc05bfd2d0d4c6dfc
3
+ metadata.gz: ed454989937d48a4eeef30f34682c4bff0f7e2a40da349eea0eeb8b5a19afb8d
4
+ data.tar.gz: 4df1828cf06d45281a58b9f3f90c2a8f8d89ca1271303611087e0c90d17d5d2d
5
5
  SHA512:
6
- metadata.gz: 1a89fcf6b169fddf3ade6b8032354460046e5be264b38ba4b6fd164a2c5caaa1fc10a5369599701aa9b03bd347a6dbff313a3b7ca36e48e12ac2557fde4ca6e4
7
- data.tar.gz: 15d575f392ac9ba39e2e5e11aa1732596f8ca9eaf43cbba72cf76ef036901d5bdd06ed40f8e5c7f5ff45afcd1038b2552c266e1bd420b0703642322c08ce2bde
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
- [travis]: https://travis-ci.org/medsolutions/openapi_rspec
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 Version](https://badge.fury.io/rb/openapi_rspec.svg)][gem]
7
- [![Build Status](https://travis-ci.org/medsolutions/openapi_rspec.svg?branch=master)][travis]
8
- [![Code Climate](https://codeclimate.com/github/medsolutions/openapi_rspec/badges/gpa.svg)][codeclimate]
9
- [![Test Coverage](https://codeclimate.com/github/medsolutions/openapi_rspec/badges/coverage.svg)][codeclimate]
6
+ [![Build](https://github.com/skryukov/openapi_rspec/workflows/Build/badge.svg)](https://github.com/skryukov/openapi_rspec/actions)
10
7
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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/medsolutions/openapi_rspec.
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: 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(/\{([^\}]*)\}/).each do |param|
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 block_given?
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(/\{([^\}]*)\}/).each do |param|
59
+ path.scan(/\{([^}]*)\}/).each do |param|
51
60
  key = param.first.to_sym
52
- if params && params[key]
53
- @path = path.gsub "{#{key}}", params.delete(key).to_s
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiRspec
4
- VERSION = "0.5"
4
+ VERSION = "0.6.0"
5
5
  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: '0.5'
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: 2020-08-13 00:00:00.000000000 Z
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: '1.1'
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: '1.1'
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.0.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