Class: RSpecSystem::Helpers::Shell

Inherits:
RSpecSystem::Helper show all
Defined in:
lib/rspec-system/helpers/shell.rb

Overview

Helper object behind RSpecSystem::Helpers#shell

Instance Attribute Summary

Attributes inherited from RSpecSystem::Helper

#opts, #rd

Instance Method Summary collapse

Methods inherited from RSpecSystem::Helper

#[], #default_node, #get_node_by_name, #name, name, properties, #refresh, #result_data, #to_hash, #to_s

Constructor Details

#initialize(opts, clr, &block) ⇒ Shell

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializer for Shell object.

This should be initialized via the helper method, not directly.

Parameters:

  • opts (Hash)

    options hash

  • clr (Object)

    caller object

  • block (Proc)

    code block

See Also:



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

def initialize(opts, clr, &block)
  # Defaults
  opts = {
    :c => opts[:command],
    :command => opts[:c],
  }.merge(opts)

  if opts[:c].nil?
    raise "Cannot use shell with no :command or :c option"
  end

  super(opts, clr, &block)
end

Instance Method Details

#executeObject

Gathers new results by executing the resource action



33
34
35
36
37
38
39
# File 'lib/rspec-system/helpers/shell.rb', line 33

def execute
  dest = opts[:n].name
  cmd = opts[:c]

  output << bold(color("#{dest}$", :green)) << " #{cmd}\n"
  RSpecSystem::NodeSet.create.run(opts)
end