summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-01-08 12:42:03 -0500
committerJames Wen <jrw2175@columbia.edu>2016-01-10 01:07:55 -0500
commitba7314901e7f13b3849cf483460a683238948c40 (patch)
treecb71fb23cfade545a518c5da9adfe142a3f29a05
parent0a1c1cac447aba9eaf101823de57bb4d1b9d73f4 (diff)
downloadbundler-ba7314901e7f13b3849cf483460a683238948c40.tar.gz
Add unit tests for `Bundler::SharedHelpers#filesystem_access`
-rw-r--r--spec/bundler/shared_helpers_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 930dd6f17c..81f78c8e21 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -170,6 +170,27 @@ describe Bundler::SharedHelpers do
end
end
end
+ describe "#filesystem_access" do
+ context "system has proper permission access" do
+ it "performs the operation in the passed block" do
+ file_op_block = proc {|path| FileUtils.mkdir_p(path) }
+ subject.filesystem_access("./test_dir", &file_op_block)
+ expect(Pathname.new("test_dir")).to exist
+ end
+ end
+ context "system throws Errno::EACESS" do
+ it "raises a PermissionError" do
+ file_op_block = proc {|_path| raise Errno::EACCES }
+ expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(Bundler::PermissionError)
+ end
+ end
+ context "system throws Errno::EAGAIN" do
+ it "raises a TemporaryResourceError" do
+ file_op_block = proc {|_path| raise Errno::EAGAIN }
+ expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(Bundler::TemporaryResourceError)
+ end
+ end
+ end
describe "#const_get_safely" do
module TargetNamespace
VALID_CONSTANT = 1