artirix_data_models 0.31.0 → 0.32.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: e0da26214f0430c9250de8d6612d9f0f6b98ad49
4
- data.tar.gz: 4dfcc8eaec6f4aaec45ef8a62fbb8c07efa52d7e
3
+ metadata.gz: 68ae21ecebbb6e23b0e20e3cc9aed1dfbe0932ea
4
+ data.tar.gz: d9e1ff08adcb57dee94cea2b69cabde6483d8451
5
5
  SHA512:
6
- metadata.gz: 266689d66972416d55e64c828709b90f58a71b5daa22e0c99d1b7f1174b763280fa0ab30cecc9b0e047ab1b58ba0cf9af2e1a46e5ada169f712c33bfc124cbc4
7
- data.tar.gz: 23a3285b7906014c27074f08f73936bfb9dc02e50d42482cdf41ea64d19a6546aafcfb2a81c646f98ecf8796ff6f6dfe4bbc1b7de422d7deea06b8b16bc12f24
6
+ metadata.gz: e2adcab677b934257e58d7579a4b65ef46b97033b6b1caf8b16e86f2bbd07dd1cf7acd503c0d46488669f9d073ab7c6614694783280200976f37b29cb179d43e
7
+ data.tar.gz: c2f3b98d7b7d9a7c1e4eb428edc936083bb754d965a3a021a818d9a8054b87b3f8b74f16dc818c6cc42c2cfb4c3a32a70f113839413aff3e3aff13957be1409d
data/README.md CHANGED
@@ -327,6 +327,10 @@ end
327
327
 
328
328
  ## Changes
329
329
 
330
+ ### 0.32.0
331
+
332
+ - minor changes to allow backwards compatibility. Better mocking of gateway.
333
+
330
334
  ### 0.31.0
331
335
 
332
336
  - `CacheAdaptor` has a `delete` method now, which calls `cache.delete cache_key`.
@@ -34,6 +34,7 @@ module ArtirixDataModels::CacheService
34
34
  def self.set_options_from_config(service)
35
35
  options = ArtirixDataModels.configuration.try(:cache_options)
36
36
  if options
37
+ options = options.to_hash if options.respond_to?(:to_hash) && !options.respond_to?(:each)
37
38
  options.each do |name, opts|
38
39
  if name.to_s == 'default_options'
39
40
  service.register_default_options opts
@@ -16,7 +16,8 @@ def given_gateway_config(connection_url = nil)
16
16
  end
17
17
  end
18
18
 
19
-
19
+ # returns the result of `expect(gateway).to EXPECTATION` or `allow(gateway).to EXPECTATION`
20
+ # yields EXPECTATION so it can be tuned, for example to add a `at_most` call to the chain
20
21
  def mock_gateway_response(response:,
21
22
  method:,
22
23
  path:,
@@ -26,25 +27,33 @@ def mock_gateway_response(response:,
26
27
  authorization_bearer: nil,
27
28
  authorization_token_hash: nil,
28
29
  gateway: nil,
29
- headers: nil)
30
+ headers: nil,
31
+ expect: false,
32
+ &block)
30
33
  gateway ||= ArtirixDataModels::DAORegistry.gateway
31
34
 
35
+ callable = block_given? ? block : ->(x) { x }
36
+
37
+ unless body.nil? || !json_body
38
+ body = body.kind_of?(String) ? body : body.to_json
39
+ end
40
+
32
41
  params_hash = {
33
- path: path,
34
- body: body,
35
- json_body: json_body,
36
- timeout: timeout,
37
- authorization_bearer: authorization_bearer,
42
+ path: path,
43
+ body: body,
44
+ json_body: json_body,
45
+ timeout: timeout,
46
+ authorization_bearer: authorization_bearer,
38
47
  authorization_token_hash: authorization_token_hash,
39
- headers: headers
48
+ headers: headers
40
49
  }
41
50
 
42
- allow(gateway).to receive(:perform).with(method, params_hash).and_return response
51
+ what_to_allow = callable.call(receive(:perform).with(method, params_hash).and_return(response))
43
52
 
44
- # check with body already parsed
45
- unless body.nil?
46
- body = body.kind_of?(String) ? body : body.to_json
47
- allow(gateway).to receive(:perform).with(method, params_hash.merge(body: body)).and_return response
53
+ if expect
54
+ expect(gateway).to what_to_allow
55
+ else
56
+ allow(gateway).to what_to_allow
48
57
  end
49
58
  end
50
59
 
@@ -61,13 +70,13 @@ def mock_gateway_not_found_response(method:,
61
70
  gateway ||= ArtirixDataModels::DAORegistry.gateway
62
71
 
63
72
  params_hash = {
64
- path: path,
65
- body: body,
66
- json_body: json_body,
67
- timeout: timeout,
68
- authorization_bearer: authorization_bearer,
73
+ path: path,
74
+ body: body,
75
+ json_body: json_body,
76
+ timeout: timeout,
77
+ authorization_bearer: authorization_bearer,
69
78
  authorization_token_hash: authorization_token_hash,
70
- headers: headers
79
+ headers: headers
71
80
  }
72
81
 
73
82
  allow(gateway).to receive(:perform).with(method, params_hash).and_raise ArtirixDataModels::DataGateway::NotFound
@@ -98,7 +98,7 @@ shared_examples_for 'an ArtirixDataModel DAO' do
98
98
  end
99
99
 
100
100
  Given do
101
- allow(ArtirixDataModels::DAORegistry).to receive(:model_fields).and_return(model_fields_dao)
101
+ allow(subject.dao_registry).to receive(:get).with(:model_fields).and_return(model_fields_dao)
102
102
  end
103
103
 
104
104
  When(:result) { subject.partial_mode_fields }
@@ -1,3 +1,3 @@
1
1
  module ArtirixDataModels
2
- VERSION = '0.31.0'
2
+ VERSION = '0.32.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artirix_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Turiño
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport