diff options
Diffstat (limited to 'spec/bundler/bundler/compact_index_client/updater_spec.rb')
-rw-r--r-- | spec/bundler/bundler/compact_index_client/updater_spec.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/spec/bundler/bundler/compact_index_client/updater_spec.rb b/spec/bundler/bundler/compact_index_client/updater_spec.rb index 26159dccd8..acb312edb3 100644 --- a/spec/bundler/bundler/compact_index_client/updater_spec.rb +++ b/spec/bundler/bundler/compact_index_client/updater_spec.rb @@ -3,28 +3,25 @@ require "net/http" require "bundler/compact_index_client" require "bundler/compact_index_client/updater" +require "tmpdir" RSpec.describe Bundler::CompactIndexClient::Updater do let(:fetcher) { double(:fetcher) } - let(:local_path) { Pathname("/tmp/localpath") } + let(:local_path) { Pathname.new Dir.mktmpdir("localpath") } let(:remote_path) { double(:remote_path) } let!(:updater) { described_class.new(fetcher) } context "when the ETag header is missing" do # Regression test for https://github.com/rubygems/bundler/issues/5463 + let(:response) { double(:response, :body => "abc123") } - let(:response) { double(:response, :body => "") } - - it "MisMatchedChecksumError is raised" do - # Twice: #update retries on failure - expect(response).to receive(:[]).with("Content-Encoding").twice { "" } - expect(response).to receive(:[]).with("ETag").twice { nil } - expect(fetcher).to receive(:call).twice { response } + it "treats the response as an update" do + expect(response).to receive(:[]).with("Content-Encoding") { "" } + expect(response).to receive(:[]).with("ETag") { nil } + expect(fetcher).to receive(:call) { response } - expect do - updater.update(local_path, remote_path) - end.to raise_error(Bundler::CompactIndexClient::Updater::MisMatchedChecksumError) + updater.update(local_path, remote_path) end end @@ -43,7 +40,8 @@ RSpec.describe Bundler::CompactIndexClient::Updater do context "when bundler doesn't have permissions on Dir.tmpdir" do it "Errno::EACCES is raised" do - allow(Dir).to receive(:mktmpdir) { raise Errno::EACCES } + local_path # create local path before stubbing mktmpdir + allow(Bundler::Dir).to receive(:mktmpdir) { raise Errno::EACCES } expect do updater.update(local_path, remote_path) |