[rubygems/rubygems] Run definition specs in an isolated location

And consistently pass Pathname's to `Definition.new` like production
code does.

https://github.com/rubygems/rubygems/commit/660def5b68
This commit is contained in:
David Rodriguez 2024-01-26 09:26:31 +01:00 коммит произвёл Hiroshi SHIBATA
Родитель 5500f880f3
Коммит 0c71fb4b86
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
1 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -5,17 +5,16 @@ require "bundler/definition"
RSpec.describe Bundler::Definition do
describe "#lock" do
before do
allow(Bundler).to receive(:settings) { Bundler::Settings.new(".") }
allow(Bundler::SharedHelpers).to receive(:find_gemfile) { Pathname.new("Gemfile") }
allow(Bundler::SharedHelpers).to receive(:find_gemfile) { bundled_app_gemfile }
allow(Bundler).to receive(:ui) { double("UI", info: "", debug: "") }
end
subject { Bundler::Definition.new("Gemfile.lock", [], Bundler::SourceList.new, {}) }
subject { Bundler::Definition.new(bundled_app_lock, [], Bundler::SourceList.new, {}) }
context "when it's not possible to write to the file" do
it "raises an PermissionError with explanation" do
allow(File).to receive(:open).and_call_original
expect(File).to receive(:open).with("Gemfile.lock", "wb").
expect(File).to receive(:open).with(bundled_app_lock, "wb").
and_raise(Errno::EACCES)
expect { subject.lock }.
to raise_error(Bundler::PermissionError, /Gemfile\.lock/)
@ -24,7 +23,7 @@ RSpec.describe Bundler::Definition do
context "when a temporary resource access issue occurs" do
it "raises a TemporaryResourceError with explanation" do
allow(File).to receive(:open).and_call_original
expect(File).to receive(:open).with("Gemfile.lock", "wb").
expect(File).to receive(:open).with(bundled_app_lock, "wb").
and_raise(Errno::EAGAIN)
expect { subject.lock }.
to raise_error(Bundler::TemporaryResourceError, /temporarily unavailable/)