Class: Umami::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-umami/test.rb,
lib/chef-umami/test/unit.rb,
lib/chef-umami/test/integration.rb

Direct Known Subclasses

Integration, Unit

Defined Under Namespace

Classes: Integration, Unit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_dir) ⇒ Test

Returns a new instance of Test.



18
19
20
# File 'lib/chef-umami/test.rb', line 18

def initialize(root_dir)
  @root_dir = root_dir
end

Instance Attribute Details

#root_dirObject (readonly)

Returns the value of attribute root_dir.



17
18
19
# File 'lib/chef-umami/test.rb', line 17

def root_dir
  @root_dir
end

Instance Method Details

#frameworkObject

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

"chefspec"
"serverspec"
"inspec"

Raises:

  • (NoMethodError)


30
31
32
# 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

#generateObject

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

Raises:

  • (NoMethodError)


57
58
59
# 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 = '') ⇒ Object

#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) }”

Raises:

  • (NoMethodError)


44
45
46
# 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) ⇒ Object

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

Raises:

  • (NoMethodError)


51
52
53
# 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