mirror of
https://github.com/inspec/inspec
synced 2024-11-30 08:30:39 +00:00
api: method_missing doesnt resolve hashmaps
Since #its has its(pun) own way of handling calls with a dot-notation, the full call is never passed to the resource. For example: ```ruby describe json('file') do its('a.b.c') { should eq 123 } end ``` This is resolved to calling `json('file').a.b.c` and thus doesnt work as an intended `json('file').send('a.b.c'). For now use regular its-behavior of calling `json('file').params ... its(%w{a b c}) { should ... }`. Its' behavior must be improved.
This commit is contained in:
parent
8d682973b0
commit
24451469ca
1 changed files with 6 additions and 3 deletions
|
@ -49,10 +49,13 @@ class JsonConfig < Inspec.resource(1)
|
|||
end
|
||||
end
|
||||
|
||||
# Shorthand to retrieve a parameter name via `#its`.
|
||||
# Example: describe json('file') { its('paramX') { should eq 'Y' } }
|
||||
#
|
||||
# @param [String] name name of the field to retrieve
|
||||
# @return [Object] the value stored at this position
|
||||
def method_missing(name)
|
||||
# split dotted path
|
||||
keys = name.to_s.split('.')
|
||||
extract_value(keys, @params.clone)
|
||||
@params[name.to_s]
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
Loading…
Reference in a new issue