Module: Beaker::DSL::Helpers::TestHelpers

Included in:
Beaker::DSL::Helpers
Defined in:
lib/beaker/dsl/helpers/test_helpers.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#current_step_nameString

Gets the currently executing test’s currently executing step name. This is set using the Structure#step method.

Returns:

  • (String)

    Step name, or nil if it hasn’t been set



31
32
33
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 31

def current_step_name
  [:step] && [:step][:name] ? [:step][:name] : nil
end

#current_test_filenameString

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

Examples:

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

canal

Returns:

  • (String)

    Test filename, or nil if it hasn’t been set



23
24
25
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 23

def current_test_filename
  [:case] && [:case][:file_name] ? [:case][:file_name] : nil
end

#current_test_nameString

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

Returns:

  • (String)

    Test name, or nil if it hasn’t been set



11
12
13
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 11

def current_test_name
  [:case] && [:case][:name] ? [:case][:name] : nil
end

#set_current_step_name(name) ⇒ Object

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.

Sets the currently executing step’s name.

Parameters:

  • name (String)

    Name of the step

Returns:

  • nil



63
64
65
66
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 63

def set_current_step_name(name)
  [:step] ||= {}
  [:step][:name] = name
end

#set_current_test_filename(filename) ⇒ Object

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.

Sets the currently executing test’s filename.

Parameters:

  • filename (String)

    Name of the file being tested

Returns:

  • nil



52
53
54
55
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 52

def set_current_test_filename(filename)
  [:case] ||= {}
  [:case][:file_name] = filename
end

#set_current_test_name(name) ⇒ Object

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.

Sets the currently executing test’s name.

Parameters:

  • name (String)

    Name of the test

Returns:

  • nil



41
42
43
44
# File 'lib/beaker/dsl/helpers/test_helpers.rb', line 41

def set_current_test_name(name)
  [:case] ||= {}
  [:case][:name] = name
end