pact 1.29.0 → 1.30.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
  SHA1:
3
- metadata.gz: b4544628feb78e41d434d8df2fa467c3795b0849
4
- data.tar.gz: 22c2d7a7caa71c7da7dd33e232a44ba5374f3fd9
3
+ metadata.gz: ae5b619b17a3e5134fea66e3e089ce3c096af93d
4
+ data.tar.gz: d8b230915ee8eadb59febb4c5551862db5bed69c
5
5
  SHA512:
6
- metadata.gz: e1e6ddfcaad18582eb50938d8599e02d19a68efc4053f26e677ccd44125d3c855d4447a13e11a900652612ba1eec1d13759d18fbf32824f8d4c686d06601f9fc
7
- data.tar.gz: 572c7b4c21f1143d3352620f4596f923917dc974c590b78a2cc9cd2fed071d9d5a5cf2ffe41e369e9cfda4ae6201713760ff3e263a6a74a34ccec747b5b3bcd4
6
+ metadata.gz: 9c4b09e2c225fbda956928c81adf1cb965c9b3bac351459fb0e7a4b4ebf22ec90dde93aa02c734f5084f83919d5dca04b2379db25c533c6db93693ec0d02ae76
7
+ data.tar.gz: e28af9fce398f9c0835bfb874320150b0ce9e2fb154c9e590b771f935b3ce3775be87a430ace03d7b6ae7b6c14c261447fc250a14246a881a600fca0b36c8028
@@ -1,3 +1,12 @@
1
+ <a name="v1.30.0"></a>
2
+ ### v1.30.0 (2018-07-24)
3
+
4
+
5
+ #### Features
6
+
7
+ * raise error when an expected HAL relation cannot be found in a resource ([5db4134](/../../commit/5db4134))
8
+
9
+
1
10
  <a name="v1.29.0"></a>
2
11
  ### v1.29.0 (2018-07-24)
3
12
 
@@ -4,8 +4,12 @@ require 'pact/hal/link'
4
4
 
5
5
  module Pact
6
6
  module Hal
7
+ class RelationNotFoundError < ::Pact::Error; end
8
+
7
9
  class Entity
8
- def initialize(data, http_client, response = nil)
10
+
11
+ def initialize(href, data, http_client, response = nil)
12
+ @href = href
9
13
  @data = data
10
14
  @links = (@data || {}).fetch("_links", {})
11
15
  @client = http_client
@@ -40,6 +44,10 @@ module Pact
40
44
  end
41
45
  end
42
46
 
47
+ def _link!(key)
48
+ _link(key) or raise RelationNotFoundError.new("Could not find relation '#{key}' in resource at #{@href}")
49
+ end
50
+
43
51
  def success?
44
52
  true
45
53
  end
@@ -69,7 +77,8 @@ module Pact
69
77
 
70
78
  class ErrorEntity < Entity
71
79
 
72
- def initialize(data, http_client, response = nil)
80
+ def initialize(href, data, http_client, response = nil)
81
+ @href = href
73
82
  @data = data
74
83
  @links = {}
75
84
  @client = http_client
@@ -25,15 +25,15 @@ module Pact
25
25
  end
26
26
 
27
27
  def get(payload = {}, headers = {})
28
- wrap_response(@http_client.get(href, payload, headers))
28
+ wrap_response(href, @http_client.get(href, payload, headers))
29
29
  end
30
30
 
31
31
  def put(payload = nil, headers = {})
32
- wrap_response(@http_client.put(href, payload ? JSON.dump(payload) : nil, headers))
32
+ wrap_response(href, @http_client.put(href, payload ? JSON.dump(payload) : nil, headers))
33
33
  end
34
34
 
35
35
  def post(payload = nil, headers = {})
36
- wrap_response(@http_client.post(href, payload ? JSON.dump(payload) : nil, headers))
36
+ wrap_response(href, @http_client.post(href, payload ? JSON.dump(payload) : nil, headers))
37
37
  end
38
38
 
39
39
  def expand(params)
@@ -44,12 +44,12 @@ module Pact
44
44
 
45
45
  private
46
46
 
47
- def wrap_response(http_response)
47
+ def wrap_response(href, http_response)
48
48
  require 'pact/hal/entity' # avoid circular reference
49
49
  if http_response.success?
50
- Entity.new(http_response.body, @http_client, http_response)
50
+ Entity.new(href, http_response.body, @http_client, http_response)
51
51
  else
52
- ErrorEntity.new(http_response.raw_body, @http_client, http_response)
52
+ ErrorEntity.new(href, http_response.raw_body, @http_client, http_response)
53
53
  end
54
54
  end
55
55
 
@@ -64,9 +64,9 @@ module Pact
64
64
 
65
65
  def link_for(tag)
66
66
  if !tag[:all]
67
- index_entity._link(LATEST_PROVIDER_TAG_RELATION)
67
+ index_entity._link!(LATEST_PROVIDER_TAG_RELATION)
68
68
  else
69
- index_entity._link(ALL_PROVIDER_TAG_RELATION)
69
+ index_entity._link!(ALL_PROVIDER_TAG_RELATION)
70
70
  end
71
71
  end
72
72
 
@@ -75,7 +75,7 @@ module Pact
75
75
  end
76
76
 
77
77
  def latest_pacts_for_provider
78
- link = index_entity._link(LATEST_PROVIDER_RELATION)
78
+ link = index_entity._link!(LATEST_PROVIDER_RELATION)
79
79
  pact_urls(link.expand(provider: provider).get)
80
80
  end
81
81
 
@@ -32,7 +32,7 @@ module Pact
32
32
  end
33
33
 
34
34
  @http_client = Pact::Hal::HttpClient.new(http_client_options)
35
- @pact_entity = Pact::Hal::Entity.new(pact_source.pact_hash, http_client)
35
+ @pact_entity = Pact::Hal::Entity.new(pact_source.uri, pact_source.pact_hash, http_client)
36
36
  end
37
37
 
38
38
  def call
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.29.0"
3
+ VERSION = "1.30.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.29.0
4
+ version: 1.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-07-24 00:00:00.000000000 Z
15
+ date: 2018-07-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp