@@ -44,13 +44,74 @@ def build_selectors(hash)
44
44
end
45
45
46
46
context "when only 2 version selectors are specified" do
47
- subject { Repository . new . find build_selectors ( "A" => "1.2.3" , "B" => "2.0.0" ) }
47
+ let ( :selectors ) { build_selectors ( "A" => "1.2.3" , "B" => "2.0.0" ) }
48
+
49
+ subject { Repository . new . find ( selectors ) }
48
50
49
51
it "only returns 1 row" do
50
52
expect ( subject . size ) . to eq 1
51
53
end
52
54
end
53
55
end
56
+
57
+ context "using the success option" do
58
+ before do
59
+ td . create_pact_with_hierarchy ( "A" , "1.2.3" , "B" )
60
+ . create_verification ( provider_version : "1.0.0" )
61
+ . create_consumer_version ( "1.2.4" )
62
+ . create_pact
63
+ . create_verification ( provider_version : "2.0.0" , success : false )
64
+ . create_consumer_version ( "1.2.5" )
65
+ . create_pact
66
+ end
67
+
68
+ let ( :selectors ) { build_selectors ( "A" => nil , "B" => nil ) }
69
+
70
+ subject { Repository . new . find ( selectors , options ) }
71
+
72
+ context "when the success option is not set" do
73
+ let ( :options ) { { } }
74
+
75
+ it "returns all rows specified by the selectors" do
76
+ expect ( subject . size ) . to eq 3
77
+ end
78
+ end
79
+
80
+ context "when the success option is true" do
81
+ let ( :options ) { { success : [ true ] } }
82
+
83
+ it "only includes successes" do
84
+ expect ( subject . first [ :provider_version_number ] ) . to eq "1.0.0"
85
+ expect ( subject . size ) . to eq 1
86
+ end
87
+ end
88
+
89
+ context "when the success option is false" do
90
+ let ( :options ) { { success : [ false ] } }
91
+
92
+ it "only includes failures" do
93
+ expect ( subject . first [ :provider_version_number ] ) . to eq "2.0.0"
94
+ expect ( subject . size ) . to eq 1
95
+ end
96
+ end
97
+
98
+ context "when the success option is nil" do
99
+ let ( :options ) { { success : [ nil ] } }
100
+
101
+ it "only includes unverified rows" do
102
+ expect ( subject . first [ :provider_version_number ] ) . to eq nil
103
+ expect ( subject . size ) . to eq 1
104
+ end
105
+ end
106
+
107
+ context "when multiple success options are specified" do
108
+ let ( :options ) { { success : [ false , nil ] } }
109
+
110
+ it "returns all matching rows" do
111
+ expect ( subject . collect { |r | r [ :provider_version_number ] } ) . to eq [ nil , "2.0.0" ]
112
+ end
113
+ end
114
+ end
54
115
end
55
116
56
117
describe "#find_for_consumer_and_provider" do
0 commit comments