Module: BeakerRSpec::BeakerShim

Includes:
Beaker::DSL
Defined in:
lib/beaker-rspec/beaker_shim.rb

Overview

BeakerShim Module

This module provides the connection between rspec and the Beaker DSL. Additional wrappers are provided around commonly executed sets of Beaker commands.

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Cleanup the testing framework, shut down test boxen and tidy up



83
84
85
# File 'lib/beaker-rspec/beaker_shim.rb', line 83

def cleanup
  @network_manager.cleanup
end

#configureObject

Run configuration steps to have hosts ready to test on (such as ensuring that hosts are correctly time synched, adding keys, etc). Assumes #setup, #provision and #validate have already been called.



48
49
50
# File 'lib/beaker-rspec/beaker_shim.rb', line 48

def configure
  @network_manager.configure
end

#default_nodeBeaker::Host

Accessor for default node

Returns:

  • (Beaker::Host)


78
79
80
# File 'lib/beaker-rspec/beaker_shim.rb', line 78

def default_node
  RSpec.configuration.default_node ||= find_only_one :default
end

#hostsArray<Beaker::Host>

Accessor for hosts object

Returns:

  • (Array<Beaker::Host>)


67
68
69
# File 'lib/beaker-rspec/beaker_shim.rb', line 67

def hosts
  RSpec.configuration.hosts
end

#hosts=(v) ⇒ Object

Setter for hosts object



72
73
74
# File 'lib/beaker-rspec/beaker_shim.rb', line 72

def hosts= v
  RSpec.configuration.hosts = v
end

#loggerObject

Accessor for logger

Returns:

  • Beaker::Logger object



14
15
16
# File 'lib/beaker-rspec/beaker_shim.rb', line 14

def logger
  RSpec.configuration.logger
end

#metadataObject

Accessor for metadata

Returns:

  • Hash metadata



20
21
22
# File 'lib/beaker-rspec/beaker_shim.rb', line 20

def 
  RSpec.configuration.
end

#optionsObject

Accessor for options hash

Returns:

  • Hash options



26
27
28
# File 'lib/beaker-rspec/beaker_shim.rb', line 26

def options
  RSpec.configuration.options
end

#provisionObject

Provision the hosts to run tests on. Assumes #setup has already been called.



33
34
35
36
# File 'lib/beaker-rspec/beaker_shim.rb', line 33

def provision
  @network_manager = Beaker::NetworkManager.new(options, @logger)
  RSpec.configuration.hosts = @network_manager.provision
end

#setup(args = []) ⇒ Object

Setup the testing environment See ‘beaker –help’ for full list of supported command line options

Parameters:

  • args (Array<String>) (defaults to: [])

    The argument array of options for configuring Beaker



55
56
57
58
59
60
61
62
63
# File 'lib/beaker-rspec/beaker_shim.rb', line 55

def setup(args = [])
  options_parser = Beaker::Options::Parser.new
  options = options_parser.parse_args(args)
  options[:debug] = true
  RSpec.configuration.logger = Beaker::Logger.new(options)
  options[:logger] = logger
  RSpec.configuration.hosts = []
  RSpec.configuration.options = options
end

#validateObject

Validate that the SUTs are up and correctly configured. Checks that required packages are installed and if they are missing attempt installation. Assumes #setup and #provision has already been called.



41
42
43
# File 'lib/beaker-rspec/beaker_shim.rb', line 41

def validate
  @network_manager.validate
end