@@ -7,6 +7,8 @@ module Decorators
7
7
describe "to_json" do
8
8
let ( :verification_date ) { DateTime . new ( 2017 , 12 , 31 ) }
9
9
let ( :pact_created_at ) { DateTime . new ( 2017 , 1 , 1 ) }
10
+ let ( :line_1_success ) { true }
11
+ let ( :line_2_success ) { true }
10
12
let ( :line_1 ) do
11
13
{
12
14
consumer_name : "Consumer" ,
@@ -15,7 +17,7 @@ module Decorators
15
17
pact_created_at : pact_created_at ,
16
18
provider_version_number : "4.5.6" ,
17
19
provider_name : "Provider" ,
18
- success : true ,
20
+ success : line_1_success ,
19
21
number : 1 ,
20
22
build_url : nil ,
21
23
verification_executed_at : verification_date
@@ -30,10 +32,10 @@ module Decorators
30
32
pact_created_at : pact_created_at ,
31
33
provider_version_number : nil ,
32
34
provider_name : "Provider" ,
33
- success : nil ,
35
+ success : line_2_success ,
34
36
number : nil ,
35
37
build_url : nil ,
36
- verification_executed_at : nil
38
+ verification_executed_at : verification_date
37
39
}
38
40
end
39
41
@@ -114,14 +116,18 @@ module Decorators
114
116
end
115
117
116
118
it "includes a summary" do
117
- expect ( parsed_json [ :summary ] [ :deployable ] ) . to eq false
119
+ expect ( parsed_json [ :summary ] [ :deployable ] ) . to eq true
120
+ expect ( parsed_json [ :summary ] [ :reason ] ) . to match /All verification results are published/
118
121
end
119
122
120
123
context "when the pact has not been verified" do
121
- let ( :verification_hash ) do
122
- nil
124
+ before do
125
+ line_2 [ :success ] = nil
126
+ line_2 [ :verification_executed_at ] = nil
123
127
end
124
128
129
+ let ( :verification_hash ) { nil }
130
+
125
131
it "has empty provider details" do
126
132
expect ( parsed_json [ :matrix ] [ 1 ] [ :provider ] ) . to eq provider_hash . merge ( version : nil )
127
133
end
@@ -130,6 +136,30 @@ module Decorators
130
136
expect ( parsed_json [ :matrix ] [ 1 ] [ :verificationResult ] ) . to eq verification_hash
131
137
end
132
138
end
139
+
140
+ context "when one or more successes are nil" do
141
+ let ( :line_1_success ) { nil }
142
+
143
+ it "has a deployable flag of nil" do
144
+ expect ( parsed_json [ :summary ] [ :deployable ] ) . to be nil
145
+ end
146
+
147
+ it "has an explanation" do
148
+ expect ( parsed_json [ :summary ] [ :reason ] ) . to match /Missing/
149
+ end
150
+ end
151
+
152
+ context "when one or more successes are false" do
153
+ let ( :line_1_success ) { false }
154
+
155
+ it "has a deployable flag of false" do
156
+ expect ( parsed_json [ :summary ] [ :deployable ] ) . to be false
157
+ end
158
+
159
+ it "has an explanation" do
160
+ expect ( parsed_json [ :summary ] [ :reason ] ) . to match /have failed/
161
+ end
162
+ end
133
163
end
134
164
end
135
165
end
0 commit comments