Sha256: 5890b94e715d13c82e9d6016f97421d66393a9e3656c31e5094124d2ba5d7193

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 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
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
beaker-2.52.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.5.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.4.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.3.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.2.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.1.0 spec/beaker/host/windows/exec_spec.rb
beaker-3.0.0 spec/beaker/host/windows/exec_spec.rb
beaker-2.51.0 spec/beaker/host/windows/exec_spec.rb
beaker-2.50.0 spec/beaker/host/windows/exec_spec.rb