Fail when `file_append' misses some arguments

This commit is contained in:
Thibault Jouan 2014-10-09 19:47:52 +00:00
parent 770f4df51e
commit 5549ebc676
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,10 @@ module Producer
module Actions
class FileAppend < Action
def setup
if arguments.compact.size != 2
fail ArgumentError, '`%s\' action requires 2 arguments' % name
end
@path, @content = arguments
end

View File

@ -12,6 +12,16 @@ module Producer::Core
before { allow(remote_fs).to receive(:file_read).with(path) { content } }
describe '#setup' do
context 'when content is missing' do
let(:added_content) { nil }
it 'raises ArgumentError' do
expect { action }.to raise_error ArgumentError
end
end
end
describe '#apply' do
it 'appends given content to requested file on remote filesystem' do
expect(remote_fs)