mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Fix attribute
with empty hash regression (#3454)
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
parent
087b6dd33c
commit
d5bb1e5fe9
4 changed files with 10 additions and 3 deletions
|
@ -142,8 +142,8 @@ module Inspec
|
|||
end
|
||||
|
||||
# method for attributes; import attribute handling
|
||||
define_method :attribute do |name, options = {}|
|
||||
if options.empty?
|
||||
define_method :attribute do |name, options = nil|
|
||||
if options.nil?
|
||||
Inspec::AttributeRegistry.find_attribute(name, profile_id).value
|
||||
else
|
||||
profile_context_owner.register_attribute(name, options)
|
||||
|
|
|
@ -29,7 +29,7 @@ describe 'attributes' do
|
|||
cmd += ' --attrs ' + File.join(profile_path, 'global_attributes', 'files', "attr.yml")
|
||||
out = inspec(cmd)
|
||||
out.stderr.must_equal ''
|
||||
out.stdout.must_include '20 successful'
|
||||
out.stdout.must_include '21 successful'
|
||||
out.exit_status.must_equal 0
|
||||
end
|
||||
|
||||
|
|
|
@ -39,3 +39,9 @@ describe 'test attribute with no defualt but has type' do
|
|||
subject { attribute('val_no_default_with_type').respond_to?(:fake_method) }
|
||||
it { should cmp true }
|
||||
end
|
||||
|
||||
empty_hash_attribute = attribute('val_with_empty_hash_default', {})
|
||||
describe 'test attribute with default as empty hash' do
|
||||
subject { empty_hash_attribute }
|
||||
it { should cmp 'success' }
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
val_user_override: bob
|
||||
val_numeric_override: 9999
|
||||
val_with_empty_hash_default: 'success'
|
||||
|
|
Loading…
Reference in a new issue