mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
3e7d47505c
* Add support for XML files Signed-off-by: Morley, Jonathan <jmorley@cvent.com> * Use REXML instead of nokogiri Signed-off-by: Morley, Jonathan <jmorley@cvent.com>
27 lines
556 B
Ruby
27 lines
556 B
Ruby
# encoding: utf-8
|
|
# author: Jonathan Morley
|
|
|
|
module Inspec::Resources
|
|
class XmlConfig < JsonConfig
|
|
name 'xml'
|
|
desc 'Use the xml InSpec resource to test configuration data in an XML file'
|
|
example "
|
|
describe xml('default.xml') do
|
|
its('key/sub_key') { should eq(['value']) }
|
|
end
|
|
"
|
|
|
|
def parse(content)
|
|
require 'rexml/document'
|
|
REXML::Document.new(content)
|
|
end
|
|
|
|
def value(key)
|
|
REXML::XPath.each(@params, key.first.to_s).map(&:text)
|
|
end
|
|
|
|
def to_s
|
|
"XML #{@path}"
|
|
end
|
|
end
|
|
end
|