Sha256: e51dbfb08a16753a70bf7f8cd90b633ec9df1b9be0fd538b7f53ae9c670255a3

Contents?: true

Size: 755 Bytes

Versions: 29

Compression:

Stored size: 755 Bytes

Contents

module Serverspec
  module Backend
    class WinRM < Base
      include PowerShell::ScriptHelper

      def run_command(cmd, opts={})
        script = create_script(cmd)
        winrm = RSpec.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

        { :stdout => stdout, :stderr => stderr,
          :exit_status => result[:exitcode], :exit_signal => nil }
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
serverspec-0.9.8 lib/serverspec/backend/winrm.rb
serverspec-0.9.7 lib/serverspec/backend/winrm.rb
serverspec-0.9.6 lib/serverspec/backend/winrm.rb
serverspec-0.9.5 lib/serverspec/backend/winrm.rb
serverspec-0.9.4 lib/serverspec/backend/winrm.rb
serverspec-0.9.3 lib/serverspec/backend/winrm.rb
serverspec-0.9.2 lib/serverspec/backend/winrm.rb
serverspec-0.9.1 lib/serverspec/backend/winrm.rb
serverspec-0.9.0 lib/serverspec/backend/winrm.rb