inspec/lib/resources/os.rb
Jared Quick 839ab3eef4 Deprecate and warn when comparing against OS name with capitals/spaces (#2397)
* 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>
2018-01-04 14:15:02 -05:00

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