Class: RSpecSystem::Helpers::Rcp

Inherits:
RSpecSystem::Helper show all
Defined in:
lib/rspec-system/helpers/rcp.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) ⇒ Rcp

Returns a new instance of Rcp.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rspec-system/helpers/rcp.rb', line 9

def initialize(opts, clr, &block)
  ns = RSpecSystem::NodeSet.create
  opts = {
    :source_path => opts[:sp],
    :destination_path => opts[:dp],
    :dp => opts[:destination_path],
    :sp => opts[:source_path],
    :destination_node => ns.default_node,
    :d => ns.default_node,
    :source_node => nil,
    :s => nil,
  }.merge(opts)

  # Try to figure out :*_node using the node helper if a string is passed
  if opts[:destination_node].is_a? String
    opts[:d] = opts[:destination_node] = get_node_by_name(opts[:destination_node])
  end
  if opts[:source_node].is_a? String
    opts[:s] = opts[:source_node] = get_node_by_name(opts[:source_node])
  end

  super(opts, clr, &block)
end

Instance Method Details

#executeObject

Gathers new results by executing the resource action



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

def execute
  ns = RSpecSystem::NodeSet.create

  result = ns.rcp(opts)
  { :success => result }
end