Sha256: e368f0169aa072b4227b6905c2ee113d76de1b0f0960e19bef78ae7bb4e22eae

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

module SpecInfra
  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

2 entries across 2 versions & 1 rubygems

Version Path
specinfra-0.0.3 lib/specinfra/backend/winrm.rb
specinfra-0.0.2 lib/specinfra/backend/winrm.rb