catch empty support clause

This commit is contained in:
Dominik Richter 2015-12-31 17:57:59 +01:00
parent af8e4e93ca
commit d6f48d3534
2 changed files with 12 additions and 2 deletions

View file

@ -47,7 +47,12 @@ module Inspec
def supports_transport?(backend)
# make sure the supports field is always an array
supp = params[:supports]
supp = [supp] unless supp.is_a?(Array)
supp = supp.is_a?(Hash) ? [supp] : Array(supp)
# with no supports specified, always return true, as there are no
# constraints on the supported backend; it is equivalent to putting
# all fields into accept-all mode
return true if supp.empty?
found = supp.find do |entry|
try_support = self.class.symbolize_keys(entry)

View file

@ -20,7 +20,12 @@ describe 'metadata with supported operating systems' do
Inspec::Metadata.finalize(res, 'mock')
res
end
it 'load a profile with empty supports clause' do
m = create_meta(nil)
m.supports_transport?(backend).must_equal true
end
it 'loads a profile which supports os ubuntu' do
m = create_meta({ 'os' => 'ubuntu' })
m.supports_transport?(backend).must_equal true