Sha256: 08e453789555847ee4e9948ba48470a58e0bef15e9dda883d1e312dfb89887a6

Contents?: true

Size: 728 Bytes

Versions: 7

Compression:

Stored size: 728 Bytes

Contents

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

    def run_command(cmd, opts={})
      set_config(:os, {:family => 'windows'})
      script = create_script(cmd)
      winrm = get_config(: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

7 entries across 7 versions & 1 rubygems

Version Path
specinfra-2.25.1 lib/specinfra/backend/winrm.rb
specinfra-2.25.0 lib/specinfra/backend/winrm.rb
specinfra-2.24.2 lib/specinfra/backend/winrm.rb
specinfra-2.24.1 lib/specinfra/backend/winrm.rb
specinfra-2.24.0 lib/specinfra/backend/winrm.rb
specinfra-2.23.0 lib/specinfra/backend/winrm.rb
specinfra-2.22.0 lib/specinfra/backend/winrm.rb