module Beaker::DSL::Helpers::TestHelpers

Methods that help you query the state of your tests, these methods do not require puppet to be installed to execute correctly

Public Instance Methods

current_step_name() click to toggle source

Gets the currently executing test’s currently executing step name. This is set using the {Beaker::DSL::Structure#step} method.

@return [String] Step name, or nil if it hasn’t been set

# File lib/beaker/dsl/helpers/test_helpers.rb, line 31
def current_step_name
  metadata[:step] && metadata[:step][:name] ? metadata[:step][:name] : nil
end
current_test_filename() click to toggle source

Gets the currently executing test’s filename, which is set from the +@path+ variable passed into the {Beaker::TestCase#initialize} method, not including the ‘.rb’ extension

@example if the path variable was man/plan/canal.rb, then the filename would be:

canal

@return [String] Test filename, or nil if it hasn’t been set

# File lib/beaker/dsl/helpers/test_helpers.rb, line 23
def current_test_filename
  metadata[:case] && metadata[:case][:file_name] ? metadata[:case][:file_name] : nil
end
current_test_name() click to toggle source

Gets the currently executing test’s name, which is set in a test using the {Beaker::DSL::Structure#test_name} method.

@return [String] Test name, or nil if it hasn’t been set

# File lib/beaker/dsl/helpers/test_helpers.rb, line 11
def current_test_name
  metadata[:case] && metadata[:case][:name] ? metadata[:case][:name] : nil
end
set_current_step_name(name) click to toggle source

Sets the currently executing step’s name.

@param [String] name Name of the step

@return nil @api private

# File lib/beaker/dsl/helpers/test_helpers.rb, line 63
def set_current_step_name(name)
  metadata[:step] ||= {}
  metadata[:step][:name] = name
end
set_current_test_filename(filename) click to toggle source

Sets the currently executing test’s filename.

@param [String] filename Name of the file being tested

@return nil @api private

# File lib/beaker/dsl/helpers/test_helpers.rb, line 52
def set_current_test_filename(filename)
  metadata[:case] ||= {}
  metadata[:case][:file_name] = filename
end
set_current_test_name(name) click to toggle source

Sets the currently executing test’s name.

@param [String] name Name of the test

@return nil @api private

# File lib/beaker/dsl/helpers/test_helpers.rb, line 41
def set_current_test_name(name)
  metadata[:case] ||= {}
  metadata[:case][:name] = name
end