Fail when `file_write' misses some arguments
This commit is contained in:
parent
ef7259fab2
commit
61c262a9f1
@ -3,6 +3,10 @@ module Producer
|
||||
module Actions
|
||||
class FileWriter < Action
|
||||
def setup
|
||||
if arguments.compact.size != 2
|
||||
fail ArgumentError, '`%s\' action requires 2 arguments' % name
|
||||
end
|
||||
|
||||
@path, @content = arguments
|
||||
@options[:permissions] = @options.delete :mode if options.key? :mode
|
||||
@options[:owner] = @options.delete :user if options.key? :user
|
||||
|
@ -2,6 +2,7 @@ module Producer
|
||||
module Core
|
||||
Error = Class.new(StandardError)
|
||||
RuntimeError = Class.new(RuntimeError)
|
||||
ArgumentError = Class.new(Error)
|
||||
ConditionNotMetError = Class.new(Error)
|
||||
RemoteCommandExecutionError = Class.new(RuntimeError)
|
||||
RegistryKeyError = Class.new(RuntimeError)
|
||||
|
@ -20,6 +20,14 @@ module Producer::Core
|
||||
it 'translates user option as owner' do
|
||||
expect(writer.options[:owner]).to eq 'root'
|
||||
end
|
||||
|
||||
context 'when content is missing' do
|
||||
let(:content) { nil }
|
||||
|
||||
it 'raises ArgumentError' do
|
||||
expect { writer }.to raise_error ArgumentError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#apply' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user