Class: SpecInfra::Backend::BeakerExec

Inherits:
Exec
  • Object
show all
Defined in:
lib/beaker-rspec/helpers/serverspec.rb

Overview

Class BeakerExec

Controls the running of Serverspec commands.

Instance Method Summary collapse

Instance Method Details

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

Run a command using serverspec. Defaults to running on the ‘default’ 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



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/beaker-rspec/helpers/serverspec.rb', line 19

def run_command(cmd, opt={})
  cmd = build_command(cmd)
  cmd = add_pre_command(cmd)
  ret = ssh_exec!(cmd)

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

  CommandResult.new ret
end