lib/resources/json.rb in inspec-2.1.54 vs lib/resources/json.rb in inspec-2.1.59
- old
+ new
@@ -1,8 +1,9 @@
# encoding: utf-8
require 'utils/object_traversal'
+require 'utils/enumerable_delegation'
require 'utils/file_reader'
module Inspec::Resources
class JsonConfig < Inspec.resource(1)
name 'json'
@@ -35,9 +36,12 @@
@params = {}
# load the raw content from the source, and then parse it
@raw_content = load_raw_content(opts)
@params = parse(@raw_content)
+
+ # If the JSON content is enumerable, make this object enumerable too
+ extend EnumerableDelegation if @params.respond_to?(:each)
end
# Shorthand to retrieve a parameter name via `#its`.
# Example: describe json('file') { its('paramX') { should eq 'Y' } }
#