Sha256: 3a64b1e9610d104c1fe1dce9709bb4dab76e50637a56180a888b5797aeae1f3a

Contents?: true

Size: 729 Bytes

Versions: 98

Compression:

Stored size: 729 Bytes

Contents

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

    def run_command(cmd, opts={})
      set :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

98 entries across 98 versions & 1 rubygems

Version Path
specinfra-2.20.1 lib/specinfra/backend/winrm.rb
specinfra-2.20.0 lib/specinfra/backend/winrm.rb
specinfra-2.19.6 lib/specinfra/backend/winrm.rb
specinfra-2.19.5 lib/specinfra/backend/winrm.rb
specinfra-2.19.4 lib/specinfra/backend/winrm.rb
specinfra-2.19.3 lib/specinfra/backend/winrm.rb
specinfra-2.19.2 lib/specinfra/backend/winrm.rb
specinfra-2.19.1 lib/specinfra/backend/winrm.rb
specinfra-2.19.0 lib/specinfra/backend/winrm.rb
specinfra-2.18.3 lib/specinfra/backend/winrm.rb
specinfra-2.18.2 lib/specinfra/backend/winrm.rb
specinfra-2.18.1 lib/specinfra/backend/winrm.rb
specinfra-2.18.0 lib/specinfra/backend/winrm.rb
specinfra-2.17.1 lib/specinfra/backend/winrm.rb
specinfra-2.17.0 lib/specinfra/backend/winrm.rb
specinfra-2.16.0 lib/specinfra/backend/winrm.rb
specinfra-2.15.2 lib/specinfra/backend/winrm.rb
specinfra-2.15.1 lib/specinfra/backend/winrm.rb
specinfra-2.15.0 lib/specinfra/backend/winrm.rb
specinfra-2.14.4 lib/specinfra/backend/winrm.rb