Class: PuppetUnitTests::DefineUsecase

Inherits:
TestUsecase show all
Defined in:
lib/puppet_unit_tests/test_usecase.rb

Overview

A test usecase for a Puppet defined type.

Instance Attribute Summary collapse

Attributes inherited from TestUsecase

#absent, #error, #facts, #hiera, #name, #present, #server_facts, #settings, #trusted_facts

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DefineUsecase

Returns a new instance of DefineUsecase.



72
73
74
75
76
77
# File 'lib/puppet_unit_tests/test_usecase.rb', line 72

def initialize(name)
  super

  @title = nil
  @parameters = {}
end

Instance Attribute Details

#parametersObject

Returns the value of attribute parameters.



70
71
72
# File 'lib/puppet_unit_tests/test_usecase.rb', line 70

def parameters
  @parameters
end

#titleObject

Returns the value of attribute title.



69
70
71
# File 'lib/puppet_unit_tests/test_usecase.rb', line 69

def title
  @title
end

Class Method Details

.parse(name, data) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/puppet_unit_tests/test_usecase.rb', line 80

def parse(name, data)
  uc = super

  if data.nil? || !data.key?("title")
    raise UserDataError, "Missing title for defined type #{@name}"
  end

  uc.title = data["title"]
  uc.parameters = data["parameters"] || {}

  uc
end