diff --git a/lib/resources/os.rb b/lib/resources/os.rb index c30cead09..667946d1f 100644 --- a/lib/resources/os.rb +++ b/lib/resources/os.rb @@ -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],