Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return STDOUT from CLI::Helpers#run

This not only effected Database::Redis#invoke_save!, where the response
from the redis-cli SAVE is expected, but also
Encryptor::GPG#extract_encryption_key_email!, where the response from
`gpg --import` is parsed for the recipient's email address.
  • Loading branch information...
commit 979bc4e66c521757c99524033138de7198f5a3d2 1 parent 7267b6a
Brian D. Burns authored Brian D. Burns committed
Showing with 10 additions and 10 deletions.
  1. +2 −2 lib/backup/cli/helpers.rb
  2. +8 −8 spec/cli/helpers_spec.rb
View
4 lib/backup/cli/helpers.rb
@@ -14,7 +14,7 @@ module Helpers
# If the command fails to execute, or returns a non-zero exit status
# an Error will be raised.
#
- # Returns nil
+ # Returns STDOUT
def run(command)
name = command_name(command)
Logger.message "Running system utility '#{ name }'..."
@@ -45,7 +45,7 @@ def run(command)
)
end
- return nil
+ return out
else
raise Errors::CLI::SystemCallError, <<-EOS
'#{ name }' Failed on #{ RUBY_PLATFORM }
View
16 spec/cli/helpers_spec.rb
@@ -29,8 +29,8 @@
let(:stdout_messages) { '' }
let(:stderr_messages) { '' }
- it 'should generate no additional log messages' do
- helpers.run(command).should be_nil
+ it 'should return stdout and generate no additional log messages' do
+ helpers.run(command).should == ''
end
end
@@ -38,11 +38,11 @@
let(:stdout_messages) { "out line1\nout line2\n" }
let(:stderr_messages) { '' }
- it 'should log the stdout messages' do
+ it 'should return stdout and log the stdout messages' do
Backup::Logger.expects(:message).with(
"cmd_name:STDOUT: out line1\ncmd_name:STDOUT: out line2"
)
- helpers.run(command).should be_nil
+ helpers.run(command).should == stdout_messages.strip
end
end
@@ -50,11 +50,11 @@
let(:stdout_messages) { '' }
let(:stderr_messages) { "err line1\nerr line2\n" }
- it 'should log the stderr messages' do
+ it 'should return stdout and log the stderr messages' do
Backup::Logger.expects(:warn).with(
"cmd_name:STDERR: err line1\ncmd_name:STDERR: err line2"
)
- helpers.run(command).should be_nil
+ helpers.run(command).should == ''
end
end
@@ -62,14 +62,14 @@
let(:stdout_messages) { "out line1\nout line2\n" }
let(:stderr_messages) { "err line1\nerr line2\n" }
- it 'should log both stdout and stderr messages' do
+ it 'should return stdout and log both stdout and stderr messages' do
Backup::Logger.expects(:message).with(
"cmd_name:STDOUT: out line1\ncmd_name:STDOUT: out line2"
)
Backup::Logger.expects(:warn).with(
"cmd_name:STDERR: err line1\ncmd_name:STDERR: err line2"
)
- helpers.run(command).should be_nil
+ helpers.run(command).should == stdout_messages.strip
end
end
end # context 'when the command is successful'
Please sign in to comment.
Something went wrong with that request. Please try again.