File tree Expand file tree Collapse file tree 4 files changed +12
-11
lines changed
Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 536536 describe "when request with headers is expected" do
537537 it "should satisfy expectation if request was executed with the same headers" do
538538 expect {
539- http_request ( :get , "http://www.example.com/" , headers : SAMPLE_HEADERS )
539+ http_request ( :get , "http://www.example.com/" , headers : SAMPLE_REQUEST_HEADERS )
540540 expect ( a_request ( :get , "www.example.com" ) .
541- with ( headers : SAMPLE_HEADERS ) ) . to have_been_made
541+ with ( headers : SAMPLE_REQUEST_HEADERS ) ) . to have_been_made
542542 } . not_to raise_error
543543 end
544544
578578
579579 it "should fail if request was executed with different headers" do
580580 expect {
581- http_request ( :get , "http://www.example.com/" , headers : SAMPLE_HEADERS )
581+ http_request ( :get , "http://www.example.com/" , headers : SAMPLE_REQUEST_HEADERS )
582582 expect ( a_request ( :get , "www.example.com" ) .
583583 with ( headers : { 'Content-Length' => '9999' } ) ) . to have_been_made
584584 } . to fail_with ( %r(The request GET http://www.example.com/ with headers \{ 'Content-Length'=>'9999'\} was expected to execute 1 time but it executed 0 times) )
606606 expect {
607607 http_request ( :post , "http://www.example.com/" ,
608608 body : "abc" ,
609- headers : SAMPLE_HEADERS
609+ headers : SAMPLE_REQUEST_HEADERS
610610 )
611611 expect ( a_request ( :post , "www.example.com" ) ) . to have_been_made
612612 } . not_to raise_error
Original file line number Diff line number Diff line change @@ -62,9 +62,9 @@ def call(request)
6262 end
6363
6464 it "should return response with declared headers" do
65- stub_request ( :get , "www.example.com" ) . to_return ( headers : SAMPLE_HEADERS )
65+ stub_request ( :get , "www.example.com" ) . to_return ( headers : SAMPLE_RESPONSE_HEADERS )
6666 response = http_request ( :get , "http://www.example.com/" )
67- expect ( response . headers [ "Accept " ] ) . to eq ( "application/json" )
67+ expect ( response . headers [ "Content-Type " ] ) . to eq ( "application/json" )
6868 unless adapter_info . include? ( :no_content_length_header )
6969 expect ( response . headers [ "Content-Length" ] ) . to eq ( "8888" )
7070 end
Original file line number Diff line number Diff line change 366366
367367 describe "based on headers" do
368368 it "should match requests if headers are the same" do
369- stub_request ( :get , "www.example.com" ) . with ( headers : { "Accept" => "application/json" } )
369+ stub_request ( :get , "www.example.com" ) . with ( headers : SAMPLE_REQUEST_HEADERS )
370370 expect ( http_request (
371371 :get , "http://www.example.com/" ,
372- headers : { "Accept" => "application/json" } ) . status ) . to eq ( "200" )
372+ headers : SAMPLE_REQUEST_HEADERS ) . status ) . to eq ( "200" )
373373 end
374374
375375 it "should match requests if headers are the same and declared as array" do
409409 stub_request ( :get , "www.example.com" )
410410 expect ( http_request (
411411 :get , "http://www.example.com/" ,
412- headers : SAMPLE_HEADERS ) . status ) . to eq ( "200" )
412+ headers : SAMPLE_REQUEST_HEADERS ) . status ) . to eq ( "200" )
413413 end
414414
415415 it "should not match requests if headers are different" do
Original file line number Diff line number Diff line change 88require 'acceptance/shared/precedence_of_stubs'
99require 'acceptance/shared/complex_cross_concern_behaviors'
1010
11- unless defined? SAMPLE_HEADERS
12- SAMPLE_HEADERS = { "Accept" => "application/json" }
11+ unless defined? SAMPLE_REQUEST_HEADERS
12+ SAMPLE_REQUEST_HEADERS = { "Accept" => "application/json" }
13+ SAMPLE_RESPONSE_HEADERS = { "Content-Type" => "application/json" , "Content-Length" => "8888" }
1314 ESCAPED_PARAMS = "x=ab%20c&z=%27Stop%21%27%20said%20Fred%20m"
1415 NOT_ESCAPED_PARAMS = "z='Stop!' said Fred m&x=ab c"
1516end
You can’t perform that action at this time.
0 commit comments