rspec_contracts 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rspec_contracts/integration.rb +5 -1
- data/lib/rspec_contracts/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88fb8dc038f7988494817b5e9a27626fa7e84d323f852035763eed94a12326d2
|
4
|
+
data.tar.gz: 77751cce1d1f15bd8b7c5a1b9f093dbdd4e8edc92dcf68a11b799fc6d3407f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e361bc74b6bc1fbfec1c91103a8841504b8d3eaccbee070ef278954b899a1520b206de8765f742dd84e73db681ff6d6830164847f3905b33045f836b19c549
|
7
|
+
data.tar.gz: af5c7cfe891c3d33c5d0e6a4fa5d655d0994872e03762325289170570dfed5d013d6b080ddf3843d522a54762948364b5ce62a935d59bf2d74b6a9c4983e86b8
|
data/README.md
CHANGED
@@ -91,7 +91,7 @@ Version constraints accept the same format as bundler in your Gemfile, so all of
|
|
91
91
|
|
92
92
|
```ruby
|
93
93
|
let(:api_call) { get pets_path, api_operation: contract["findPets"], api_version: "~> 1.1.0" }
|
94
|
-
let(:api_call) { get pets_path, api_operation: contract["findPets"], api_version: ">= 1.1.0, < 2" }
|
94
|
+
let(:api_call) { get pets_path, api_operation: contract["findPets"], api_version: [">= 1.1.0", "< 2"] }
|
95
95
|
let(:api_call) { get pets_path, api_operation: contract["findPets"], api_version: "1.1.0" }
|
96
96
|
```
|
97
97
|
|
@@ -4,6 +4,10 @@ module RspecContracts
|
|
4
4
|
module Integration
|
5
5
|
http_verbs = %w[get post patch put delete]
|
6
6
|
|
7
|
+
def version_satisfied?(constraints, api_version)
|
8
|
+
Array(constraints).all? {|constraint| Semverse::Constraint.new(constraint).satisfies?(api_version) }
|
9
|
+
end
|
10
|
+
|
7
11
|
http_verbs.each do |method|
|
8
12
|
define_method(method) do |*args, **kwargs|
|
9
13
|
request_path = args.first
|
@@ -11,7 +15,7 @@ module RspecContracts
|
|
11
15
|
api_version = kwargs.delete(:api_version)
|
12
16
|
super(*args, **kwargs).tap do |status_code|
|
13
17
|
next unless api_operation # even a not found contract lookup will still be present
|
14
|
-
next if api_version.present? && !
|
18
|
+
next if api_version.present? && !version_satisfied?(api_version, api_operation.root.version)
|
15
19
|
raise RspecContracts::Error::OperationLookup.new("Operation not found") unless api_operation.valid?
|
16
20
|
|
17
21
|
RspecContracts.config.logger.tagged("rspec_contracts", api_operation.operation_id) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -311,7 +311,7 @@ files:
|
|
311
311
|
- lib/rspec_contracts/response_validator.rb
|
312
312
|
- lib/rspec_contracts/version.rb
|
313
313
|
- lib/tasks/rspec_contracts_tasks.rake
|
314
|
-
homepage: https://github.com/tractionguest/
|
314
|
+
homepage: https://github.com/tractionguest/rspec_contracts
|
315
315
|
licenses:
|
316
316
|
- MIT
|
317
317
|
metadata: {}
|
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
330
|
- !ruby/object:Gem::Version
|
331
331
|
version: '0'
|
332
332
|
requirements: []
|
333
|
-
rubygems_version: 3.
|
333
|
+
rubygems_version: 3.2.3
|
334
334
|
signing_key:
|
335
335
|
specification_version: 4
|
336
336
|
summary: Contract testing for Rspec requests
|