Sha256: bc28b8677a027b6570d6c9842cee2a74b0a18beadfc7810f28f3fe58a6155afd
Contents?: true
Size: 1.89 KB
Versions: 4
Compression:
Stored size: 1.89 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Imap::Backup::Utils do context '#check_permissions' do before :each do File.stub!(:exist?).and_return(true) end it 'should stat the file' do stat = stub('File::Stat', :mode => 0100) File.should_receive(:stat).with('foobar').and_return(stat) Imap::Backup::Utils.check_permissions('foobar', 0345) end it 'should succeed if file permissions are less than limit' do stat = stub('File::Stat', :mode => 0100) File.stub!(:stat).and_return(stat) expect do Imap::Backup::Utils.check_permissions('foobar', 0345) end.to_not raise_error end it 'should succeed if file permissions are equal to limit' do stat = stub('File::Stat', :mode => 0345) File.stub!(:stat).and_return(stat) expect do Imap::Backup::Utils.check_permissions('foobar', 0345) end.to_not raise_error end it 'should fail if file permissions are over the limit' do stat = stub('File::Stat', :mode => 0777) File.stub!(:stat).and_return(stat) expect do Imap::Backup::Utils.check_permissions('foobar', 0345) end.to raise_error(RuntimeError, "Permissions on 'foobar' should be 0345, not 0777") end end context '#make_folder' do it 'should do nothing if an empty path is supplied' do FileUtils.should_not_receive(:mkdir_p) Imap::Backup::Utils.make_folder('aaa', '', 0222) end it 'should create the path' do FileUtils.stub!(:chmod) FileUtils.should_receive(:mkdir_p).with('/base/path/new/folder') Imap::Backup::Utils.make_folder('/base/path', 'new/folder', 0222) end it 'should set permissions on the path' do FileUtils.stub!(:mkdir_p) FileUtils.should_receive(:chmod).with(0222, '/base/path/new/folder') Imap::Backup::Utils.make_folder('/base/path/new', 'folder', 0222) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
imap-backup-1.0.9 | spec/unit/utils_spec.rb |
imap-backup-1.0.8 | spec/unit/utils_spec.rb |
imap-backup-1.0.7 | spec/unit/utils_spec.rb |
imap-backup-1.0.6 | spec/unit/utils_spec.rb |