From 28e346e4f95551697229104ace51f4a7417b5ed3 Mon Sep 17 00:00:00 2001 From: Bundlerbot Date: Sun, 9 Dec 2018 22:40:36 +0000 Subject: Merge #6834 6834: Allow files other than Gemfile.lock to be opened in definition specs r=hsbt a=segiddins ### What was the end-user problem that led to this PR? The problem was the specs are brittle. ### What was your diagnosis of the problem? My diagnosis was we should assume code can open other files. ### What is your fix for the problem, implemented in this PR? My fix allows other files to be opened, and only raises when opening the file under test. Co-authored-by: Samuel Giddins (cherry picked from commit cca1f63bffc47c7b016810d24e13e2dd4fdced12) --- spec/bundler/definition_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb index a38c0b05b0..a27c5b0a54 100644 --- a/spec/bundler/definition_spec.rb +++ b/spec/bundler/definition_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Bundler::Definition do subject { Bundler::Definition.new(nil, [], Bundler::SourceList.new, []) } it "raises an PermissionError with explanation" do + allow(File).to receive(:open).and_call_original expect(File).to receive(:open).with("Gemfile.lock", "wb"). and_raise(Errno::EACCES) expect { subject.lock("Gemfile.lock") }. @@ -23,6 +24,7 @@ RSpec.describe Bundler::Definition do subject { Bundler::Definition.new(nil, [], Bundler::SourceList.new, []) } it "raises a TemporaryResourceError with explanation" do + allow(File).to receive(:open).and_call_original expect(File).to receive(:open).with("Gemfile.lock", "wb"). and_raise(Errno::EAGAIN) expect { subject.lock("Gemfile.lock") }. -- cgit v1.2.1