Improve `file_append' when file doesn't exist

This commit is contained in:
Thibault Jouan
2014-04-13 21:45:42 +00:00
parent b995ef2680
commit 3610427c74
2 changed files with 12 additions and 1 deletions

View File

@@ -15,7 +15,10 @@ module Producer
end end
def combined_content def combined_content
fs.file_read(path) + content original_content = fs.file_read(path)
return content unless original_content
original_content + content
end end
end end
end end

View File

@@ -36,6 +36,14 @@ module Producer::Core
it 'returns original content and added content combined' do it 'returns original content and added content combined' do
expect(action.combined_content).to eq 'some content added' expect(action.combined_content).to eq 'some content added'
end end
context 'when fs.file_read returns nil' do
before { allow(remote_fs).to receive(:file_read).with(path) { nil } }
it 'returns only the added content' do
expect(action.combined_content).to eq ' added'
end
end
end end
end end
end end