class Umami::Test

Attributes

root_dir[R]

Public Class Methods

new(root_dir) click to toggle source
# File lib/chef-umami/test.rb, line 18
def initialize(root_dir)
  @root_dir = root_dir
end

Public Instance Methods

framework() click to toggle source

framework should return a string describing the framework it's expected to write tests for. Examples:

"chefspec"
"serverspec"
"inspec"
# File lib/chef-umami/test.rb, line 30
def framework
  raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test."
end
generate() click to toggle source

Performs the necessary steps to generate one or more tests within a test file.

# File lib/chef-umami/test.rb, line 57
def generate
  raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test."
end
preamble(recipe = '') click to toggle source

preamble should return a string (with newlines) that will appear at the top of a test file. Expects a string representing the recipe name, at least. Example: “# #{test_root}/#{recipe}_spec.rbn” \ “n” \ “require '#{framework}'n” \ “n” \ “describe '#{recipe}' don” \ “ let(:chef_run) { ChefSpec::ServerRunner.converge(described_recipe) }”

# File lib/chef-umami/test.rb, line 44
def preamble(recipe = '')
  raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test."
end
write_test(resource = nil) click to toggle source

write_test should write a single, discreet test for a given resource. Return as a string with newlines. Expects a Chef::Resource object.

# File lib/chef-umami/test.rb, line 51
def write_test(resource = nil)
  raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test."
end