service_contract 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/service_contract/assertions.rb +4 -0
- data/lib/service_contract/avro/endpoint.rb +5 -0
- data/lib/service_contract/version.rb +1 -1
- data/test/assertions_test.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ece676fe679b6486a503e341a6b566b67e19cbd
|
4
|
+
data.tar.gz: 54a78577a17d36b8b3541185aeede59dcb2b32f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29275de62be450eab48f0d59a2e620e922db90d71747a63bb4129d361ed416b6a6136f2854ddb72198a3c246b922f25491325de2fc942b449196c1fffd0b9a07
|
7
|
+
data.tar.gz: fc9814bb7a0615a27c8cc4210c87eca4bc371381efd93af0c4d6379b35d8258eb8177004acfdbbca004a39610506fa37e439e95c72c5bd7481a49fb6f733b1a9
|
@@ -16,6 +16,10 @@ module ServiceContract
|
|
16
16
|
# type should have fields
|
17
17
|
type.fields.each do |field|
|
18
18
|
|
19
|
+
#Does data contain attributes that the contract doesn't specify?
|
20
|
+
data_extra_attrs = (data.keys.map(&:to_sym) - type.fields.map{|n| n.name.to_sym})
|
21
|
+
assert_equal 0, data_extra_attrs.size, "#{type.name} contains attributes not described in contract: #{data_extra_attrs.join(',')}"
|
22
|
+
|
19
23
|
# ensure the field is present
|
20
24
|
value = data.fetch(field.name) do
|
21
25
|
data.fetch(field.name.to_sym) do
|
data/test/assertions_test.rb
CHANGED
@@ -58,4 +58,24 @@ class AssertionsTest < Minitest::Test
|
|
58
58
|
assert_endpoint_response([{customer_id: [1,2,3]}], endpoint)
|
59
59
|
end
|
60
60
|
|
61
|
+
def test_uncontracted_data_not_matching
|
62
|
+
service = SampleService.find(2)
|
63
|
+
assert service, "expect to find a service by version"
|
64
|
+
|
65
|
+
protocol = service.protocol("search_param")
|
66
|
+
endpoint = protocol.endpoint("index")
|
67
|
+
|
68
|
+
# test can be nil
|
69
|
+
failure_data = nil
|
70
|
+
begin
|
71
|
+
assert_endpoint_response([{customer_id: nil, bogus_param: 1}], endpoint)
|
72
|
+
rescue Minitest::Assertion => failure
|
73
|
+
failure_data = failure
|
74
|
+
end
|
75
|
+
|
76
|
+
assert !failure_data.nil?
|
77
|
+
assert failure_data.to_s.include?("not described in contract: bogus_param")
|
78
|
+
|
79
|
+
end
|
80
|
+
|
61
81
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|