diff options
author | Thom May <thom@chef.io> | 2016-02-16 11:23:41 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-02-16 11:24:02 +0000 |
commit | 4f512bc777a89c614ebf436cf8a0c48f49ee4ccc (patch) | |
tree | 5cb63d346d87a65d6d713257b61a0a625b379b09 | |
parent | 357950127954094da7052e14edf887dbb7ed98de (diff) | |
download | chef-4f512bc777a89c614ebf436cf8a0c48f49ee4ccc.tar.gz |
Add test to ensure Tempfile does the right thingcmluciano/fixhttperror
-rw-r--r-- | spec/unit/http_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb index 12c3bfcaef..69e59ecaf8 100644 --- a/spec/unit/http_spec.rb +++ b/spec/unit/http_spec.rb @@ -28,6 +28,8 @@ end describe Chef::HTTP do + let(:uri) { "https://chef.example/organizations/default/" } + context "when given a chefzero:// URL" do let(:uri) { URI("chefzero://localhost:1") } @@ -67,6 +69,18 @@ describe Chef::HTTP do end # create_url + describe "#stream_to_tempfile" do + + it "should only close an existing Tempfile" do + resp = Net::HTTPOK.new("1.1", 200, "OK") + http = Chef::HTTP.new(uri) + expect(Tempfile).to receive(:open).and_raise("TestError") + expect_any_instance_of(Tempfile).not_to receive(:close!) + expect { http.send(:stream_to_tempfile, uri, resp) }.to raise_error("TestError") + end + + end + describe "head" do it 'should return nil for a "200 Success" response (CHEF-4762)' do @@ -91,8 +105,6 @@ describe Chef::HTTP do describe "retrying connection errors" do - let(:uri) { "https://chef.example/organizations/default/" } - subject(:http) { Chef::HTTP.new(uri) } # http#http_client gets stubbed later, so eager create |