Accept mode as argument in `file_write' action
This commit is contained in:
@@ -14,6 +14,16 @@ module Producer::Core
|
||||
expect(remote_fs).to receive(:file_write).with(path, content)
|
||||
writer.apply
|
||||
end
|
||||
|
||||
context 'when a mode was given' do
|
||||
subject(:writer) { FileWriter.new(env, path, content, 0600) }
|
||||
|
||||
it 'specifies the given mode' do
|
||||
expect(remote_fs)
|
||||
.to receive(:file_write).with(anything, anything, 0600)
|
||||
writer.apply
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#path' do
|
||||
@@ -27,6 +37,20 @@ module Producer::Core
|
||||
expect(writer.content).to eq content
|
||||
end
|
||||
end
|
||||
|
||||
describe '#mode' do
|
||||
it 'returns nil' do
|
||||
expect(writer.mode).to be nil
|
||||
end
|
||||
|
||||
context 'when a mode was given' do
|
||||
subject(:writer) { FileWriter.new(env, path, content, 0600) }
|
||||
|
||||
it 'returns the mode' do
|
||||
expect(writer.mode).to eq 0600
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -126,7 +126,7 @@ module Producer::Core
|
||||
let(:content) { 'some_content' }
|
||||
|
||||
it 'opens the file' do
|
||||
expect(sftp_file).to receive(:open).with(path, 'w')
|
||||
expect(sftp_file).to receive(:open).with(path, 'w', anything)
|
||||
fs.file_write path, content
|
||||
end
|
||||
|
||||
@@ -137,6 +137,11 @@ module Producer::Core
|
||||
end
|
||||
fs.file_write path, content
|
||||
end
|
||||
|
||||
it 'accepts an optional mode argument' do
|
||||
expect(sftp_file).to receive(:open).with(anything, anything, 0600)
|
||||
fs.file_write path, content, 0600
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user