@@ -16,6 +16,7 @@ module Configuration
16
16
}
17
17
end
18
18
let ( :tags ) { [ 'master' ] }
19
+ let ( :fetch_pacts ) { double ( 'FetchPacts' ) }
19
20
20
21
before do
21
22
allow ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . and_return ( fetch_pacts )
@@ -82,8 +83,6 @@ module Configuration
82
83
end
83
84
end
84
85
85
- let ( :fetch_pacts ) { double ( 'FetchPacts' ) }
86
-
87
86
it "raises an error" do
88
87
expect { subject } . to raise_error Pact ::Error , /Please provide a pact_broker_base_url/
89
88
end
@@ -97,8 +96,6 @@ module Configuration
97
96
end
98
97
end
99
98
100
- let ( :fetch_pacts ) { double ( 'FetchPacts' ) }
101
-
102
99
it "coerces the value into an array" do
103
100
expect ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . with ( anything , [ { tag : "master" , latest : true } ] , anything , anything , anything , anything )
104
101
subject
@@ -112,22 +109,65 @@ module Configuration
112
109
end
113
110
end
114
111
115
- let ( :fetch_pacts ) { double ( 'FetchPacts' ) }
116
-
117
112
it "creates an instance of FetchPacts with an emtpy array for the consumer_version_tags" do
118
113
expect ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . with ( anything , [ ] , anything , anything , anything , anything )
119
114
subject
120
115
end
121
116
end
122
117
123
- context "when no verbose flag is provided" do
118
+ context "when the old format of selector is supplied to the consumer_verison_tags" do
119
+ let ( :tags ) { [ { name : 'main' , all : true , fallback : 'fallback' } ] }
120
+
124
121
subject do
125
122
PactVerificationFromBroker . build ( provider_name , provider_version_tags ) do
126
123
pact_broker_base_url base_url
124
+ consumer_version_tags tags
127
125
end
128
126
end
129
127
130
- let ( :fetch_pacts ) { double ( 'FetchPacts' ) }
128
+ it "converts them to selectors" do
129
+ expect ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . with ( anything , [ { tag : "main" , latest : false , fallbackTag : 'fallback' } ] , anything , anything , anything , anything )
130
+ subject
131
+ end
132
+ end
133
+
134
+ context "when an invalid class is used for the consumer_version_tags" do
135
+ let ( :tags ) { [ true ] }
136
+
137
+ subject do
138
+ PactVerificationFromBroker . build ( provider_name , provider_version_tags ) do
139
+ pact_broker_base_url base_url
140
+ consumer_version_tags tags
141
+ end
142
+ end
143
+
144
+ it "raises an error" do
145
+ expect { subject } . to raise_error Pact ::Error , "The value supplied for consumer_version_tags must be a String or a Hash. Found TrueClass"
146
+ end
147
+ end
148
+
149
+ context "when consumer_version_selectors are provided" do
150
+ let ( :tags ) { [ { tag : 'main' , latest : true , fallback_tag : 'fallback' } ] }
151
+
152
+ subject do
153
+ PactVerificationFromBroker . build ( provider_name , provider_version_tags ) do
154
+ pact_broker_base_url base_url
155
+ consumer_version_selectors tags
156
+ end
157
+ end
158
+
159
+ it "converts the casing of the key names" do
160
+ expect ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . with ( anything , [ { tag : "main" , latest : true , fallbackTag : 'fallback' } ] , anything , anything , anything , anything )
161
+ subject
162
+ end
163
+ end
164
+
165
+ context "when no verbose flag is provided" do
166
+ subject do
167
+ PactVerificationFromBroker . build ( provider_name , provider_version_tags ) do
168
+ pact_broker_base_url base_url
169
+ end
170
+ end
131
171
132
172
it "creates an instance of FetchPactURIsForVerification with verbose: false" do
133
173
expect ( Pact ::PactBroker ::FetchPactURIsForVerification ) . to receive ( :new ) . with ( anything , anything , anything , anything , hash_including ( verbose : false ) , anything )
0 commit comments