service_contract 0.5.0 → 0.5.1

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: 958fc813b28a607f6fb71c40dee6afd54e04b57c
4
- data.tar.gz: 21f8bd6925f79b150546c34c1ccc1244f69616e9
3
+ metadata.gz: c79089bb4c45ecaf89930c3812b31434739a80ef
4
+ data.tar.gz: 77e970ad260efe58fb4b2bd084bedce070a43305
5
5
  SHA512:
6
- metadata.gz: bc126bb04f0f3511eb3d921afc8a2aead84764fe5732266a63fdcf487cc400ddc17ebc9266ef58c9797c0f9484c74f7fe144efbd13bf56a8b31128f431d9a7da
7
- data.tar.gz: c912a0cf26a8a25a12b9bb43bd24b2e72f4feab3ef8a8f86b60952f49d78b97ffdd1f37e4bc5331cccac819253b7b5134c60f6308534549e17588da9147a1aeb
6
+ metadata.gz: d9394895b5246c3ec59b2523b58dce7a88389a90b0c6b00ff62cd63987c6e8c4b838b11145ad4113c5cdf94cc6c358d106516eaf27d87a5f903b3a1a3c50ed4f
7
+ data.tar.gz: f8f775dd3f259e8fb7a1d0ea5108c4b645905205784e6e0815d9a0a19261fefb36a0b84843b773f324746ae031fd13fd25a62fa0e6a0fc28ed4123455b4dfaee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1
4
+
5
+ * update failed assertion message to give you better information on why the data didn't match the contract
6
+
3
7
  ## 0.5.0
4
8
 
5
9
  * add map types
@@ -2,21 +2,21 @@ module ServiceContract
2
2
  module Assertions
3
3
 
4
4
  def assert_endpoint_response(data, endpoint, allow_nil = true)
5
- assert_data_matches_type(data, endpoint.response_type, allow_nil)
5
+ assert_data_matches_type(data, endpoint.response_type, endpoint.name, allow_nil)
6
6
  end
7
7
 
8
- def assert_data_matches_type(data, type, allow_nil = true)
8
+ def assert_data_matches_type(data, type, name, allow_nil = true)
9
9
  # Skip out if object is nil and allowed to be nil
10
10
  return true if data.nil? && allow_nil
11
11
 
12
12
  # basic type checking
13
- assert type.valid_type?(data), "expected `#{data}` (#{type.name}) to be one of #{type.valid_ruby_types}"
13
+ assert type.valid_type?(data), "expected `#{data}` (#{name}) to be one of #{type.valid_ruby_types}, instead got a #{data.class.name}"
14
14
  assert type.valid_value?(data), "#{data} is not an allowed value of type: #{type.name}"
15
15
 
16
16
  # check subtype
17
17
  if type.subtype
18
18
  data.each do |datum|
19
- assert_data_matches_type(datum, type.subtype, allow_nil)
19
+ assert_data_matches_type(datum, type.subtype, type.name, allow_nil)
20
20
  end
21
21
  end
22
22
 
@@ -34,7 +34,7 @@ module ServiceContract
34
34
  end
35
35
 
36
36
  # check the data type
37
- assert_data_matches_type(value, field.type, allow_nil)
37
+ assert_data_matches_type(value, field.type, field.name, allow_nil)
38
38
  end
39
39
  end
40
40
 
@@ -1,3 +1,3 @@
1
1
  module ServiceContract
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_contract
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Ching
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro