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