@@ -246,6 +246,52 @@ def build_selectors(hash)
246
246
expect ( subject . size ) . to eq 1
247
247
end
248
248
end
249
+
250
+ context "when the latest version is specified for a provider without a tag" do
251
+ before do
252
+ td . create_pact_with_hierarchy ( "A" , "1.2.3" , "B" )
253
+ . create_verification ( provider_version : "1.0.0" )
254
+ . use_provider_version ( "1.0.0" )
255
+ . create_verification ( provider_version : "2.0.0" , number : 2 )
256
+ . use_provider_version ( "2.0.0" )
257
+ . create_verification ( provider_version : "3.0.0" , number : 3 )
258
+ end
259
+
260
+ let ( :selectors ) do
261
+ [
262
+ { pacticipant_name : "A" , pacticipant_version_number : "1.2.3" } ,
263
+ { pacticipant_name : "B" , latest : true }
264
+ ]
265
+ end
266
+
267
+ subject { Repository . new . find ( selectors ) }
268
+
269
+ it "returns the row for the version " do
270
+ expect ( subject . first ) . to include provider_version_number : "3.0.0"
271
+ expect ( subject . size ) . to eq 1
272
+ end
273
+ end
274
+
275
+ context "when the latest version is specified for a provider without a tag but the latest known version for a provider does not have a verification" do
276
+ before do
277
+ td . create_pact_with_hierarchy ( "A" , "1.2.3" , "B" )
278
+ . create_verification ( provider_version : "1.0.0" )
279
+ . create_provider_version ( "5.0.0" )
280
+ end
281
+
282
+ let ( :selectors ) do
283
+ [
284
+ { pacticipant_name : "A" , pacticipant_version_number : "1.2.3" } ,
285
+ { pacticipant_name : "B" , latest : true }
286
+ ]
287
+ end
288
+
289
+ subject { Repository . new . find ( selectors ) }
290
+
291
+ it "returns no data - this may be confusing. Might need to re-think this logic." do
292
+ expect ( subject . size ) . to eq 0
293
+ end
294
+ end
249
295
end
250
296
251
297
describe "#find_for_consumer_and_provider" do
0 commit comments