Sha256: 6e28c6caa45bd519a420e1785de1db0aac3549756e0825ea62001a48e807a324
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
require 'helper' module SSHKit module Backend class TestPrinter < UnitTest def block_to_run lambda do |host| within '/opt/sites/example.com' do execute 'date' execute :ls, '-l', '/some/directory' with rails_env: :production do within :tmp do as :root do execute :touch, 'restart.txt' end end end end end end def printer Printer.new(Host.new(:'example.com'), &block_to_run) end def test_simple_printing sio = StringIO.new SSHKit.capture_output(sio) do printer.run end sio.rewind result = sio.read assert_equal <<-EOEXPECTED.unindent, result 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sshkit-0.0.4 | test/unit/backends/test_printer.rb |
sshkit-0.0.3 | test/unit/backends/test_printer.rb |