Sha256: 2a5d320a4f448accf438aacd713ecc7c886645abb0f801df025e03c9f3942c12
Contents?: true
Size: 1.45 KB
Versions: 17
Compression:
Stored size: 1.45 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 result = String.new SSHKit.capture_output(result) do printer.run end 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
17 entries across 17 versions & 1 rubygems