Class: Specinfra::Backend::BeakerCygwin

Inherits:
BeakerBase
  • Object
show all
Includes:
PowerShell::ScriptHelper
Defined in:
lib/beaker-rspec/helpers/serverspec.rb

Instance Method Summary collapse

Methods inherited from BeakerBase

#example, #ssh_exec!

Instance Method Details

#run_command(cmd, opt = {}) ⇒ Hash

Run a windows style command using serverspec. Defaults to running on the 'default_node' test node, otherwise uses the node specified in @example.metadata

Parameters:

  • cmd (String)

    The serverspec command to executed

  • opt (Hash) (defaults to: {})

    No currently supported options

Returns:

  • (Hash)

    Returns a hash containing :exit_status, :stdout and :stderr


235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 235

def run_command(cmd, opt = {})
  node = get_working_node
  script = create_script(cmd)
  on node, "rm -f script.ps1"
  create_remote_file(node, 'script.ps1', script)
  # cygwin support /dev/null, if running from winrm would use < NULL
  ret = ssh_exec!(node, "powershell.exe -File script.ps1 < /dev/null")

  if @example
    @example.[:command] = script
    @example.[:stdout]  = ret[:stdout]
  end

  CommandResult.new ret
end