@@ -165,6 +165,13 @@ def do_run_request(method=:GET, data=false, limit=10, raw=false)
165165 Net ::HTTP . stub! ( :new ) . and_return ( @http_mock )
166166 @rest . run_request ( method , @url_mock , { } , data , limit , raw )
167167 end
168+
169+ it "should always include the X-Chef-Version header" do
170+ Net ::HTTP ::Get . should_receive ( :new ) . with ( "/?foo=bar" ,
171+ { 'Accept' => 'application/json' , 'X-Chef-Version' => Chef ::VERSION }
172+ ) . and_return ( @request_mock )
173+ do_run_request
174+ end
168175
169176 it "should raise an exception if the redirect limit is 0" do
170177 lambda { @rest . run_request ( :GET , "/" , { } , false , 0 ) } . should raise_error ( ArgumentError )
@@ -269,36 +276,36 @@ def do_run_request(method=:GET, data=false, limit=10, raw=false)
269276 it "should set the cookie for this request if one exists for the given host:port" do
270277 @rest . cookies = { "#{ @url_mock . host } :#{ @url_mock . port } " => "cookie monster" }
271278 Net ::HTTP ::Get . should_receive ( :new ) . with ( "/?foo=bar" ,
272- { 'Accept' => 'application/json' , 'Cookie' => 'cookie monster' }
279+ { 'Accept' => 'application/json' , 'X-Chef-Version' => Chef :: VERSION , ' Cookie' => 'cookie monster' }
273280 ) . and_return ( @request_mock )
274281 do_run_request
275282 @rest . cookies = Hash . new
276283 end
277284
278285 it "should build a new HTTP GET request" do
279286 Net ::HTTP ::Get . should_receive ( :new ) . with ( "/?foo=bar" ,
280- { 'Accept' => 'application/json' }
287+ { 'Accept' => 'application/json' , 'X-Chef-Version' => Chef :: VERSION }
281288 ) . and_return ( @request_mock )
282289 do_run_request
283290 end
284291
285292 it "should build a new HTTP POST request" do
286293 Net ::HTTP ::Post . should_receive ( :new ) . with ( "/?foo=bar" ,
287- { 'Accept' => 'application/json' , "Content-Type" => 'application/json' }
294+ { 'Accept' => 'application/json' , "Content-Type" => 'application/json' , 'X-Chef-Version' => Chef :: VERSION }
288295 ) . and_return ( @request_mock )
289296 do_run_request ( :POST , @data_mock )
290297 end
291298
292299 it "should build a new HTTP PUT request" do
293300 Net ::HTTP ::Put . should_receive ( :new ) . with ( "/?foo=bar" ,
294- { 'Accept' => 'application/json' , "Content-Type" => 'application/json' }
301+ { 'Accept' => 'application/json' , "Content-Type" => 'application/json' , 'X-Chef-Version' => Chef :: VERSION }
295302 ) . and_return ( @request_mock )
296303 do_run_request ( :PUT , @data_mock )
297304 end
298305
299306 it "should build a new HTTP DELETE request" do
300307 Net ::HTTP ::Delete . should_receive ( :new ) . with ( "/?foo=bar" ,
301- { 'Accept' => 'application/json' }
308+ { 'Accept' => 'application/json' , 'X-Chef-Version' => Chef :: VERSION }
302309 ) . and_return ( @request_mock )
303310 do_run_request ( :DELETE )
304311 end
@@ -360,7 +367,7 @@ def do_run_request(method=:GET, data=false, limit=10, raw=false)
360367 end
361368
362369 it "should build a new HTTP GET request without the application/json accept header for raw reqs" do
363- Net ::HTTP ::Get . should_receive ( :new ) . with ( "/?foo=bar" , { } ) . and_return ( @request_mock )
370+ Net ::HTTP ::Get . should_receive ( :new ) . with ( "/?foo=bar" , { 'X-Chef-Version' => Chef :: VERSION } ) . and_return ( @request_mock )
364371 do_run_request ( :GET , false , 10 , true )
365372 end
366373
0 commit comments