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

Returns:

  • (Pathname)


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

Returns:

  • (Pathname)


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

Returns:

  • (Boolean)


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

Returns:

  • (Hash)

    nodeset configuration



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

Returns:



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

Returns:

  • (Pathname)


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

Returns:

  • (String)

    current virtual env type



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

  puts "Starting nodes"
  puts
  puts "Setname is: " + ns.setname
  puts "Configuration is: " + ns.config.pretty_inspect
  puts "Virtual Environment type is: #{ns.env_type}"
  puts "Default node is: #{ns.default_node.name}"
  puts "Destroy node is: #{ns.destroy}"
  puts

  ns.setup

  puts
  puts "Finished starting nodes"
  puts "================================================================="
  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
# File 'lib/rspec-system/internal_helpers.rb', line 90

def stop_nodes
  puts 'Stopping nodes'
  puts
  rspec_system_node_set.teardown
  puts 'Finished stopping nodes'
  puts "================================================================="
  nil
end