rspec_contracts 0.1.4 → 0.2.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: 416990094d07bd3e4a083be651518350f4a730fad14feb0e109d99710ea2b0f4
4
- data.tar.gz: 734de59f3870c8afb9231bf55b8712c8fd61c244f8178f5dcf09ec1cbb3a7a39
3
+ metadata.gz: 4054a2553651cf96248d039eaea4a792d267bce17552717159359d44f7f128ac
4
+ data.tar.gz: cfbb288db3943923e489f34614a1e5d4dff4fbda4f48c594f732d7f5fac4a514
5
5
  SHA512:
6
- metadata.gz: 1360e61a50dd701ca97deae3228f541e897712da1c6a9ce86c7a7e7f934cc4bf35e5e2f1434bee891f758402e3d8854534feaf4bac8686ae6faff71b7a780975
7
- data.tar.gz: 33716e95b8cad067992ce6423a3c6b58ec16e22400f90ef2f77cb3812df74690c42f824fadf28240b4389724ab6913c9ddb45c8b4452e98152f1a47f4f949dcf
6
+ metadata.gz: 015e607d259d71a90f30c6e32c240189a318ae8504ddbf4efe865fbe0ddafd3f0d8c33952e4feaab22c5903d6cf6e4a375c730d4f5df5d728ff1ed3c48230d7e
7
+ data.tar.gz: b6d77cebe29dcce5c53a189590ac3ca0417b1b474fd0f24ea11c28c2ab24912fa93adef9d54d06acf31ae05e64b3591cae8afbe36adf9c01e359e93566ad8a6a
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,7 +4,7 @@ module RspecContracts
4
4
  class Contract
5
5
  def initialize(schema)
6
6
  @schema = schema.with_indifferent_access
7
- @root = OpenAPIParser.parse(schema)
7
+ @root = OpenAPIParser.parse(schema, strict_reference_validation: true)
8
8
  end
9
9
 
10
10
  def [](key)
@@ -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.2.0"
5
5
  end
metadata CHANGED
@@ -1,35 +1,35 @@
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.2.0
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: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
20
- - - "<"
19
+ version: 6.1.7
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 6.1.0
22
+ version: 6.1.7.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
30
- - - "<"
29
+ version: 6.1.7
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 6.1.0
32
+ version: 6.1.7.3
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-rails
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -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.3.26
334
334
  signing_key:
335
335
  specification_version: 4
336
336
  summary: Contract testing for Rspec requests