openapi_contracts 0.4.2 → 0.5.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 +13 -0
- data/lib/openapi_contracts/matchers/match_openapi_doc.rb +3 -2
- data/lib/openapi_contracts/matchers.rb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3e3dc1d42240d09f42ae82d8d959014bb63f67f2b00bbf42f1a85e2fb77a916
|
4
|
+
data.tar.gz: 919c5209c05e64820cbaf9671f9ae4ed9056a8e1910bfff92a5ac9d80f6d338a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10c5edf9610a7bc35d5dfccc257a0974d52e1c3ee9be6262b90d70f4c59e682ba7eba0a745d657e69e1ffb0a6cc1571dbaf97651f3c235b9e6e19d15259f479
|
7
|
+
data.tar.gz: 5e12d9c329ff4b175c1136fdcbfd199f597a006f7a1e2436c6e91c54e9987eb43c19b58edd25e7ed7831144908b4fefefbf79c0786abe31c3707d41882557a79
|
data/README.md
CHANGED
@@ -43,6 +43,19 @@ it 'responds with 200 and matches the doc' do
|
|
43
43
|
}
|
44
44
|
```
|
45
45
|
|
46
|
+
### Options
|
47
|
+
|
48
|
+
The `match_openapi_doc($doc)` method allows passing options as a 2nd argument.
|
49
|
+
This allows overriding the default request.path lookup in case this does not find
|
50
|
+
the correct response definition in your schema. This is especially important with
|
51
|
+
dynamic paths.
|
52
|
+
|
53
|
+
Example:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
it { is_expected.to match_openapi_doc($api_doc, path: '/messages/{id}').with_http_status(:ok) }
|
57
|
+
```
|
58
|
+
|
46
59
|
### How it works
|
47
60
|
|
48
61
|
It uses the `request.path`, `request.method`, `status` and `headers` on the test subject (which must be the response) to find the response schema in the OpenAPI document. Then it does the following checks:
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module OpenapiContracts
|
2
2
|
module Matchers
|
3
3
|
class MatchOpenapiDoc
|
4
|
-
def initialize(doc)
|
4
|
+
def initialize(doc, options)
|
5
5
|
@doc = doc
|
6
|
+
@options = options
|
6
7
|
@errors = []
|
7
8
|
end
|
8
9
|
|
@@ -43,7 +44,7 @@ module OpenapiContracts
|
|
43
44
|
|
44
45
|
def response_spec
|
45
46
|
@response_spec ||= @doc.response_for(
|
46
|
-
@response.request.path,
|
47
|
+
@options.fetch(:path, @response.request.path),
|
47
48
|
@response.request.request_method.downcase,
|
48
49
|
@response.status.to_s
|
49
50
|
)
|
@@ -2,8 +2,8 @@ module OpenapiContracts
|
|
2
2
|
module Matchers
|
3
3
|
autoload :MatchOpenapiDoc, 'openapi_contracts/matchers/match_openapi_doc'
|
4
4
|
|
5
|
-
def match_openapi_doc(doc)
|
6
|
-
MatchOpenapiDoc.new(doc)
|
5
|
+
def match_openapi_doc(doc, options = {})
|
6
|
+
MatchOpenapiDoc.new(doc, options)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mkon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 3.0.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 3.0.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,28 +78,28 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - '='
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 1.
|
81
|
+
version: 1.36.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - '='
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.
|
88
|
+
version: 1.36.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rubocop-rspec
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - '='
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 2.
|
95
|
+
version: 2.12.1
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.
|
102
|
+
version: 2.12.1
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: simplecov
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|