@@ -184,7 +184,7 @@ def common_headers
184
184
185
185
should 'allow to set options for Manticore' do
186
186
options = { headers : { 'User-Agent' => 'myapp-0.0' } }
187
- transport = Manticore . new hosts : [ { host : 'foobar' , port : 1234 } ] , options : options
187
+ transport = Manticore . new ( hosts : [ { host : 'foobar' , port : 1234 } ] , options : options )
188
188
transport . connections . first . connection
189
189
. expects ( :get )
190
190
. with do |_host , _options |
@@ -209,13 +209,35 @@ def common_headers
209
209
transport = Manticore . new hosts : [ { host : 'foobar' , port : 1234 } ] , options : options
210
210
end
211
211
212
+ should 'allow custom headers' do
213
+ transport_options = { headers : { 'Authorization' => 'Basic token' } }
214
+ transport = Manticore . new (
215
+ hosts : [ { host : 'foobar' , port : 1234 } ] ,
216
+ transport_options : transport_options
217
+ )
218
+
219
+ assert_equal (
220
+ transport . instance_variable_get ( :@request_options ) [ :headers ] [ 'Authorization' ] ,
221
+ 'Basic token'
222
+ )
223
+ transport . connections . first . connection
224
+ . expects ( :get )
225
+ . with do |_host , _options |
226
+ assert_equal ( 'Basic token' , _options [ :headers ] [ 'Authorization' ] )
227
+ true
228
+ end
229
+ . returns ( stub_everything )
230
+
231
+ transport . perform_request ( 'GET' , '/' , { } )
232
+ end
233
+
212
234
should 'pass :transport_options to Manticore::Client' do
213
235
options = {
214
236
transport_options : { potatoes : 1 }
215
237
}
216
238
217
239
::Manticore ::Client . expects ( :new ) . with ( potatoes : 1 , ssl : { } )
218
- transport = Manticore . new hosts : [ { host : 'foobar' , port : 1234 } ] , options : options
240
+ transport = Manticore . new ( hosts : [ { host : 'foobar' , port : 1234 } ] , options : options )
219
241
end
220
242
end
221
243
end
0 commit comments