mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
839ab3eef4
* Testing train downcase platform names. * Added NameCleaned tests and fixed some formatting. * Clean up tests with helper method. * Update to new gemfile and platform resource. Signed-off-by: Jared Quick <jquick@chef.io>
46 lines
1 KiB
Ruby
46 lines
1 KiB
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
require 'resources/platform'
|
|
|
|
module Inspec::Resources
|
|
class OSResource < PlatformResource
|
|
name 'os'
|
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
|
example "
|
|
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
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows? hpux? darwin?}.each do |os_family|
|
|
define_method(os_family.to_sym) do
|
|
@platform.send(os_family)
|
|
end
|
|
end
|
|
|
|
# helper to collect a hash object easily
|
|
def params
|
|
{
|
|
name: name,
|
|
family: @platform[:family],
|
|
release: @platform[:release],
|
|
arch: @platform[:arch],
|
|
}
|
|
end
|
|
|
|
def to_s
|
|
'Operating System Detection'
|
|
end
|
|
end
|
|
end
|