diff options
author | John Keiser <jkeiser@opscode.com> | 2013-10-09 12:26:27 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-10-09 12:26:27 -0700 |
commit | a5337fcad5ed979078b6cf57c7e1e6ec8f0b76cf (patch) | |
tree | 11a5e98513f9496d3ce15a823e7a84cd4d178f58 /spec/unit/rest_spec.rb | |
parent | 836705dee684032baa85920c808a3eca5f5a8a87 (diff) | |
download | chef-a5337fcad5ed979078b6cf57c7e1e6ec8f0b76cf.tar.gz |
Use new Chef::ServerAPI API class in upload/download/diff
Diffstat (limited to 'spec/unit/rest_spec.rb')
-rw-r--r-- | spec/unit/rest_spec.rb | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb index 9352afad11..fddb3dc407 100644 --- a/spec/unit/rest_spec.rb +++ b/spec/unit/rest_spec.rb @@ -76,27 +76,46 @@ describe Chef::REST do end it "makes a :GET request with the composed url object" do - @rest.should_receive(:request).with(:GET, @monkey_uri, {}) + @rest.should_receive(:send_http_request). + with(:GET, @monkey_uri, STANDARD_READ_HEADERS, false). + and_return([1,2,3]) + @rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) + @rest.should_receive('success_response?'.to_sym).with(1).and_return(true) @rest.get_rest("monkey") end it "makes a :GET reqest for a streaming download with the composed url" do - @rest.should_receive(:streaming_request).with(@monkey_uri, {}) + @rest.should_receive(:streaming_request).with('monkey', {}) @rest.get_rest("monkey", true) end - it "makes a :DELETE request with the composed url object" do - @rest.should_receive(:request).with(:DELETE, @monkey_uri, {}) + STANDARD_READ_HEADERS = {"Accept"=>"application/json", "Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"} + STANDARD_WRITE_HEADERS = {"Accept"=>"application/json", "Content-Type"=>"application/json", "Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"} + + it "makes a :DELETE request with the composed url object" do + @rest.should_receive(:send_http_request). + with(:DELETE, @monkey_uri, STANDARD_READ_HEADERS, false). + and_return([1,2,3]) + @rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) + @rest.should_receive('success_response?'.to_sym).with(1).and_return(true) @rest.delete_rest("monkey") end it "makes a :POST request with the composed url object and data" do - @rest.should_receive(:request).with(:POST, @monkey_uri, {}, "data") + @rest.should_receive(:send_http_request). + with(:POST, @monkey_uri, STANDARD_WRITE_HEADERS, "\"data\""). + and_return([1,2,3]) + @rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) + @rest.should_receive('success_response?'.to_sym).with(1).and_return(true) @rest.post_rest("monkey", "data") end it "makes a :PUT request with the composed url object and data" do - @rest.should_receive(:request).with(:PUT, @monkey_uri, {}, "data") + @rest.should_receive(:send_http_request). + with(:PUT, @monkey_uri, STANDARD_WRITE_HEADERS, "\"data\""). + and_return([1,2,3]) + @rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) + @rest.should_receive('success_response?'.to_sym).with(1).and_return(true) @rest.put_rest("monkey", "data") end end |