Accept mode as argument in `mkdir' action

This commit is contained in:
Thibault Jouan
2014-04-25 00:28:20 +00:00
parent 5cb6296057
commit 94f6bbb4aa
6 changed files with 68 additions and 7 deletions

View File

@@ -13,6 +13,15 @@ module Producer::Core
expect(remote_fs).to receive(:mkdir).with(path)
mkdir.apply
end
context 'when a mode was given' do
subject(:mkdir) { Mkdir.new(env, path, 0700) }
it 'creates the directory with given mode' do
expect(remote_fs).to receive(:mkdir).with(anything, 0700)
mkdir.apply
end
end
end
describe '#path' do
@@ -20,6 +29,20 @@ module Producer::Core
expect(mkdir.path).to eq path
end
end
describe '#mode' do
it 'returns nil' do
expect(mkdir.mode).to be nil
end
context 'when a mode was given' do
subject(:mkdir) { Mkdir.new(env, path, 0700) }
it 'returns the mode' do
expect(mkdir.mode).to be 0700
end
end
end
end
end
end

View File

@@ -89,9 +89,16 @@ module Producer::Core
let(:path) { 'some_directory_path' }
it 'creates the directory' do
expect(sftp).to receive(:mkdir!).with(path)
expect(sftp).to receive(:mkdir!).with(path, anything)
fs.mkdir path
end
it 'specifies permissions from optional mode argument' do
expect(sftp).to receive(:mkdir!) do |_, options|
expect(options[:permissions]).to eq 0700
end
fs.mkdir path, 0700
end
end
describe '#file_read' do