diff --git a/lib/producer/core/actions/shell_command.rb b/lib/producer/core/actions/shell_command.rb index 92eb265..5dc56cd 100644 --- a/lib/producer/core/actions/shell_command.rb +++ b/lib/producer/core/actions/shell_command.rb @@ -2,12 +2,17 @@ module Producer module Core module Actions class ShellCommand < Action + def setup + check_arguments_size! 1 + @command = arguments.first + end + def name 'sh' end def apply - remote.execute(arguments.first, output, error_output) + remote.execute(@command, output, error_output) end end end diff --git a/spec/producer/core/actions/shell_command_spec.rb b/spec/producer/core/actions/shell_command_spec.rb index 9ec9c6d..82ceef2 100644 --- a/spec/producer/core/actions/shell_command_spec.rb +++ b/spec/producer/core/actions/shell_command_spec.rb @@ -10,6 +10,16 @@ module Producer::Core it_behaves_like 'action' + describe '#setup' do + context 'when command is missing' do + let(:command) { nil } + + it 'raises ArgumentError' do + expect { sh }.to raise_error ArgumentError + end + end + end + describe '#apply' do it 'executes the remote command' do expect_execution(command)