add helper methods for os resource

This commit is contained in:
Christoph Hartmann 2016-05-30 10:32:28 +02:00 committed by Dominik Richter
parent c77da82fca
commit 9e753a5dbc

View file

@ -7,9 +7,17 @@ module Inspec::Resources
name 'os'
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
example "
describe os[:family] do
describe os.family do
it { should eq 'redhat' }
end
describe os.redhat? do
it { should eq true }
end
describe os.linux? do
it { should eq true }
end
"
# reuse helper methods from backend
@ -25,6 +33,15 @@ module Inspec::Resources
inspec.backend.os[name]
end
# add helper methods for easy access of properties
# allows users to use os.name, os.family, os.release, os.arch
%w{name family release arch}.each do |property|
define_method(property.to_sym) do
inspec.backend.os[property.to_sym]
end
end
# helper to collect a hash object easily
def params
{
name: inspec.backend.os[:name],