spec/unit/imap/backup/utils_spec.rb in imap-backup-2.1.1 vs spec/unit/imap/backup/utils_spec.rb in imap-backup-2.2.0
- old
+ new
@@ -3,12 +3,12 @@
let(:stat) { instance_double(File::Stat, mode: mode) }
let(:mode) { 0o777 }
let(:exists) { true }
before do
- allow(File).to receive(:stat).and_return(stat)
- allow(File).to receive(:exist?).with(filename).and_return(exists)
+ allow(File).to receive(:stat) { stat }
+ allow(File).to receive(:exist?).with(filename) { exists }
end
describe ".check_permissions" do
let(:requested) { 0o345 }
@@ -70,24 +70,23 @@
allow(FileUtils).to receive(:mkdir_p)
allow(FileUtils).to receive(:chmod)
end
it "does nothing if an empty path is supplied" do
- described_class.make_folder("aaa", "", 0o222)
+ expect(FileUtils).to_not receive(:mkdir_p)
- expect(FileUtils).to_not have_received(:mkdir_p)
+ described_class.make_folder("aaa", "", 0o222)
end
it "creates the path" do
- described_class.make_folder("/base/path", "new/folder", 0o222)
+ expect(FileUtils).to receive(:mkdir_p).with("/base/path/new/folder")
- expect(FileUtils).to have_received(:mkdir_p).with("/base/path/new/folder")
+ described_class.make_folder("/base/path", "new/folder", 0o222)
end
it "sets permissions on the path" do
- described_class.make_folder("/base/path/new", "folder", 0o222)
+ expect(FileUtils).to receive(:chmod).with(0o222, "/base/path/new/folder")
- expect(FileUtils).
- to have_received(:chmod).with(0o222, "/base/path/new/folder")
+ described_class.make_folder("/base/path/new", "folder", 0o222)
end
end
end