test/unit/backends/test_printer.rb in sshkit-0.0.2 vs test/unit/backends/test_printer.rb in sshkit-0.0.3
- old
+ new
@@ -2,22 +2,10 @@
module SSHKit
module Backend
- class ToSIoFormatter < StringIO
- extend Forwardable
- attr_reader :original_output
- def_delegators :@original_output, :read, :rewind
- def initialize(oio)
- @original_output = oio
- end
- def write(obj)
- original_output.write "> Executing #{obj}\n"
- end
- end
-
class TestPrinter < UnitTest
def block_to_run
lambda do |host|
within '/opt/sites/example.com' do
@@ -37,22 +25,22 @@
def printer
Printer.new(Host.new(:'example.com'), &block_to_run)
end
def test_simple_printing
- sio = ToSIoFormatter.new(StringIO.new)
+ sio = StringIO.new
SSHKit.capture_output(sio) do
printer.run
end
sio.rewind
result = sio.read
assert_equal <<-EOEXPECTED.unindent, result
- > Executing if test ! -d /opt/sites/example.com; then echo "Directory does not exist '/opt/sites/example.com'" 1>&2; false; fi
- > Executing cd /opt/sites/example.com && /usr/bin/env date
- > Executing cd /opt/sites/example.com && /usr/bin/env ls -l /some/directory
- > Executing if test ! -d /opt/sites/example.com/tmp; then echo "Directory does not exist '/opt/sites/example.com/tmp'" 1>&2; false; fi
- > Executing if ! sudo su root -c whoami > /dev/null; then echo "You cannot switch to user 'root' using sudo, please check the sudoers file" 1>&2; false; fi
- > Executing cd /opt/sites/example.com/tmp && ( RAILS_ENV=production sudo su root -c /usr/bin/env touch restart.txt )
+ if test ! -d /opt/sites/example.com; then echo "Directory does not exist '/opt/sites/example.com'" 1>&2; false; fi
+ cd /opt/sites/example.com && /usr/bin/env date
+ cd /opt/sites/example.com && /usr/bin/env ls -l /some/directory
+ if test ! -d /opt/sites/example.com/tmp; then echo "Directory does not exist '/opt/sites/example.com/tmp'" 1>&2; false; fi
+ if ! sudo su root -c whoami > /dev/null; then echo "You cannot switch to user 'root' using sudo, please check the sudoers file" 1>&2; false; fi
+ cd /opt/sites/example.com/tmp && ( RAILS_ENV=production sudo su root -c /usr/bin/env touch restart.txt )
EOEXPECTED
end
end