Module: RSpecSystem::InternalHelpers Private

Included in:
Helper, Node
Defined in:
lib/rspec-system/internal_helpers.rb

Overview

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

This is a helper module that exposes some internal helpers used by the main public ones, also the startup and teardown routines.

Instance Method Summary collapse

Instance Method Details

#custom_prefabs_pathPathname

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.

Return the path to the custom prefabs file



18
19
20
# File 'lib/rspec-system/internal_helpers.rb', line 18

def custom_prefabs_path
  Pathname.new(File.expand_path(File.join(File.basename(__FILE__), '..', '.prefabs.yml')))
end

#nodesetPathname

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.

Return the path to the nodeset file



11
12
13
# File 'lib/rspec-system/internal_helpers.rb', line 11

def nodeset
  Pathname.new(File.join(File.basename(__FILE__), '..', '.nodeset.yml'))
end

#rspec_destroyBoolean

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.

Defines if a set will be destroyed before and after tests



48
49
50
51
# File 'lib/rspec-system/internal_helpers.rb', line 48

def rspec_destroy
  return false if ENV["RSPEC_DESTROY"] =~ /(no|false)/
  return true
end

#rspec_system_configHash

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.

Return the nodeset configuration hash



34
35
36
# File 'lib/rspec-system/internal_helpers.rb', line 34

def rspec_system_config
  YAML.load_file('.nodeset.yml')
end

#rspec_system_node_setRSpecSystem::NodeSet::Base

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.

Return the current nodeset object



56
57
58
59
60
61
62
# File 'lib/rspec-system/internal_helpers.rb', line 56

def rspec_system_node_set
  setname = ENV['RSPEC_SET'] || rspec_system_config['default_set']
  config = rspec_system_config['sets'][setname]
  options = {}
  options[:destroy] = rspec_destroy
  RSpecSystem::NodeSet.create(setname, config, rspec_virtual_env, custom_prefabs_path, options)
end

#rspec_system_tmpPathname

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.

Return the path to the temporary directory



25
26
27
28
29
# File 'lib/rspec-system/internal_helpers.rb', line 25

def rspec_system_tmp
  path = ENV["RSPEC_SYSTEM_TMP"] || File.expand_path(File.join(File.basename(__FILE__), '..', '.rspec_system'))
  FileUtils.mkdir_p(path)
  Pathname.new(path)
end

#rspec_virtual_envString

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.

Grab the type of virtual environment we wish to run these tests in



41
42
43
# File 'lib/rspec-system/internal_helpers.rb', line 41

def rspec_virtual_env
  ENV["RSPEC_VIRTUAL_ENV"] || 'vagrant'
end

#start_nodesvoid

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.

This method returns an undefined value.

Start all nodes



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rspec-system/internal_helpers.rb', line 67

def start_nodes
  ns = rspec_system_node_set

  output << "=begin===========================================================\n"
  output << "\n"
  output << bold("Starting nodes") << "\n"
  output << "\n"
  output << bold("Setname:") << "             #{ns.setname}\n"
  output << bold("Configuration:") << "       #{ns.config.pretty_inspect}"
  output << bold("Virtual Environment:") << " #{ns.env_type}\n"
  output << bold("Default node:") << "        #{ns.default_node.name}\n"
  output << bold("Destroy node:") << "        #{ns.destroy}\n"
  output << "\n"
  ns.setup
  output << "\n"
  output << "=end=============================================================\n"
  output << "\n"
  nil
end

#stop_nodesvoid

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.

This method returns an undefined value.

Stop all nodes



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rspec-system/internal_helpers.rb', line 90

def stop_nodes
  output << "\n"
  output << "=begin===========================================================\n"
  output << "\n"
  output << bold("Stopping nodes\n")
  output << "\n"
  rspec_system_node_set.teardown
  output << "\n"
  output << "=end=============================================================\n"
  nil
end