Class: Example::Control

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec-plugin-example/control.rb

Class Method Summary collapse

Class Method Details



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/inspec-plugin-example/control.rb', line 14

def self.print
  Inspec::Log.debug "Example::Control debugging message"
  # Example of adding a Control
  ctrl = ::Inspec::Control.new
  ctrl.id = "InSpecPluginExample"
  ctrl.title = "Example of an InSpec Control"
  ctrl.desc = "Description of an Example InSpec Control"
  ctrl.impact = "1.0"
  # Example of adding a Resource
  describe = ::Inspec::Describe.new
  # describes the Resource with the id as argument
  describe.qualifier.push(["file", "/tmp/test.txt"])
  # ensure the Resource exists
  describe.add_test(nil, "exist", nil)
  # example of testing a Resource
  describe.add_test("mode", "cmp", "0644")

  ctrl.add_test(describe)

  # print out the Control
  puts "title 'Example File Title'\n\n"
  puts ctrl.to_ruby
end