diff --git a/features/actions/sh.feature b/features/actions/sh.feature index 858113a..8c8c35e 100644 --- a/features/actions/sh.feature +++ b/features/actions/sh.feature @@ -19,11 +19,11 @@ Feature: `sh' task action target 'some_host.test' task :some_task do - sh '\echo from remote' + sh '\echo hello from remote' end """ When I successfully execute the recipe - Then the output must contain "from remote" + Then the output must contain exactly "hello from remote\n" Scenario: aborts on failed command execution Given a recipe with: diff --git a/lib/producer/core/actions/shell_command.rb b/lib/producer/core/actions/shell_command.rb index a578b48..718ca86 100644 --- a/lib/producer/core/actions/shell_command.rb +++ b/lib/producer/core/actions/shell_command.rb @@ -4,7 +4,6 @@ module Producer class ShellCommand < Action def apply remote.execute(arguments.first, output) - output.puts end end end diff --git a/lib/producer/core/testing/mock_remote.rb b/lib/producer/core/testing/mock_remote.rb index bddae6b..e623d90 100644 --- a/lib/producer/core/testing/mock_remote.rb +++ b/lib/producer/core/testing/mock_remote.rb @@ -12,7 +12,7 @@ module Producer case program when 'echo' - output << tokens.join(' ') + output << tokens.join(' ') << "\n" when 'true' output << '' when 'false' diff --git a/spec/producer/core/actions/shell_command_spec.rb b/spec/producer/core/actions/shell_command_spec.rb index 6b2b851..dbef67d 100644 --- a/spec/producer/core/actions/shell_command_spec.rb +++ b/spec/producer/core/actions/shell_command_spec.rb @@ -15,7 +15,7 @@ module Producer::Core sh.apply end - it 'writes the returned output with a record separator' do + it 'writes the returned output' do sh.apply expect(output).to eq "#{command_args}\n" end diff --git a/spec/producer/core/testing/mock_remote_spec.rb b/spec/producer/core/testing/mock_remote_spec.rb index aef8238..2b5d762 100644 --- a/spec/producer/core/testing/mock_remote_spec.rb +++ b/spec/producer/core/testing/mock_remote_spec.rb @@ -20,8 +20,8 @@ module Producer::Core context 'dummy echo command' do let(:command) { 'echo some arguments' } - it 'returns command arguments' do - expect(remote.execute(command)).to eq 'some arguments' + it 'returns command arguments ended by a record separator' do + expect(remote.execute(command)).to eq "some arguments\n" end end