Sha256: 3d7b99821d12d97685e5cafeafb1e80a5908758400d00bce1737655789a76a53

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

module Specinfra::Backend
  class Winrm < Base
    include PowerShell::ScriptHelper

    def run_command(cmd, opts={})
      Specinfra.configuration.os = { :family => 'windows' }
      script = create_script(cmd)
      winrm = Specinfra.configuration.winrm

      result = winrm.powershell(script)
      stdout, stderr = [:stdout, :stderr].map do |s|
        result[:data].select {|item| item.key? s}.map {|item| item[s]}.join
      end
      result[:exitcode] = 1 if result[:exitcode] == 0 and !stderr.empty?

      if @example
        @example.metadata[:command] = script
        @example.metadata[:stdout]  = stdout + stderr
      end

      CommandResult.new :stdout => stdout, :stderr => stderr, :exit_status => result[:exitcode]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
specinfra-2.21.1 lib/specinfra/backend/winrm.rb
specinfra-2.21.0 lib/specinfra/backend/winrm.rb
specinfra-2.20.2 lib/specinfra/backend/winrm.rb