mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
add helper methods for os resource
This commit is contained in:
parent
c77da82fca
commit
9e753a5dbc
1 changed files with 18 additions and 1 deletions
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue