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:
Dominik Richter 2015-10-27 15:55:32 +01:00
parent 8d682973b0
commit 24451469ca

View file

@ -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