Sha256: 2cdeb4b66a9e91f66c25509d1056d8f4108dd453da7231e8dfb15b8ee1156b6c

Contents?: true

Size: 2 KB

Versions: 15

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

module Beaker
  describe Windows::Exec do
    class WindowsExecTest
      include Windows::Exec

      def initialize(hash, logger)
        @hash = hash
        @logger = logger
      end

      def [](k)
        @hash[k]
      end

      def to_s
        "me"
      end

    end

    let (:opts)     { @opts || {} }
    let (:logger)   { double( 'logger' ).as_null_object }
    let (:instance) { WindowsExecTest.new(opts, logger) }

    describe '#prepend_commands' do
      it 'sets spacing correctly if both parts are defined' do
        allow( instance ).to receive( :is_cygwin? ).and_return( true )
        command_str = instance.prepend_commands( 'command', 'pants', { :cmd_exe => true } )
        expect( command_str ).to be === 'cmd.exe /c pants'
      end

      it 'sets spacing empty if one is not supplied' do
        allow( instance ).to receive( :is_cygwin? ).and_return( true )
        command_str = instance.prepend_commands( 'command', 'pants' )
        expect( command_str ).to be === 'pants'
      end

      it 'does not use cmd.exe by default' do
        allow( instance ).to receive( :is_cygwin? ).and_return( true )
        command_str = instance.prepend_commands( 'pants' )
        expect( command_str ).not_to match( /cmd\.exe/ )
      end
    end

    describe '#selinux_enabled?' do
      it 'does not call selinuxenabled' do
        expect(Beaker::Command).not_to receive(:new).with("sudo selinuxenabled")
        expect(instance).not_to receive(:exec).with(0, :accept_all_exit_codes => true)
        expect(instance.selinux_enabled?).to be === false
      end
    end

    describe '#reboot' do
      it 'invokes the correct command on the host' do
        expect( Beaker::Command ).to receive( :new ).with( /^shutdown \/f \/r \/t 0 \/d p:4:1 \/c "Beaker::Host reboot command issued"/ ).and_return( :foo )
        expect( instance ).to receive( :exec ).with( :foo, :reset_connection => true )
        expect( instance ).to receive( :sleep )
        instance.reboot
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
beaker-3.20.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.19.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.18.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.17.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.16.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.15.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.14.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.13.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.12.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.11.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.10.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.9.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.8.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.7.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.6.0 spec/beaker/host/windows/exec_spec.rb