rspec_contracts 0.1.4 → 0.1.5

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: 416990094d07bd3e4a083be651518350f4a730fad14feb0e109d99710ea2b0f4
4
- data.tar.gz: 734de59f3870c8afb9231bf55b8712c8fd61c244f8178f5dcf09ec1cbb3a7a39
3
+ metadata.gz: 88fb8dc038f7988494817b5e9a27626fa7e84d323f852035763eed94a12326d2
4
+ data.tar.gz: 77751cce1d1f15bd8b7c5a1b9f093dbdd4e8edc92dcf68a11b799fc6d3407f82
5
5
  SHA512:
6
- metadata.gz: 1360e61a50dd701ca97deae3228f541e897712da1c6a9ce86c7a7e7f934cc4bf35e5e2f1434bee891f758402e3d8854534feaf4bac8686ae6faff71b7a780975
7
- data.tar.gz: 33716e95b8cad067992ce6423a3c6b58ec16e22400f90ef2f77cb3812df74690c42f824fadf28240b4389724ab6913c9ddb45c8b4452e98152f1a47f4f949dcf
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? && !Semverse::Constraint.new(api_operation.root.version).include?(api_version)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RspecContracts
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
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
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: 2020-07-05 00:00:00.000000000 Z
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/rspec-openapi-validator
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.0.3
333
+ rubygems_version: 3.2.3
334
334
  signing_key:
335
335
  specification_version: 4
336
336
  summary: Contract testing for Rspec requests