2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/toml"
|
2017-06-15 20:54:12 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::TOML" do
|
|
|
|
describe "when loading valid TOML" do
|
2019-05-31 21:59:06 +00:00
|
|
|
let(:resource) { load_resource("toml", "default.toml") }
|
2017-06-15 20:54:12 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "gets params as a hash" do
|
2017-06-15 20:54:12 +00:00
|
|
|
_(resource.params).must_be_kind_of Hash
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves nil if a param is missing" do
|
|
|
|
_(resource.params["missing"]).must_be_nil
|
2017-06-15 20:54:12 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves params by name" do
|
|
|
|
_(resource.params["key"]).must_equal "value"
|
2017-06-15 20:54:12 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves array by name" do
|
|
|
|
_(resource.params["arr"]).must_be_kind_of Array
|
|
|
|
_(resource.params["arr"]).must_equal [1, 2, 3]
|
2017-06-15 20:54:12 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves table by name as hash" do
|
|
|
|
h = { "key1" => "value1", "key2" => "value2" }
|
|
|
|
_(resource.params["mytable"]).must_be_kind_of Hash
|
|
|
|
_(resource.params["mytable"]).must_equal h
|
2017-06-15 20:54:12 +00:00
|
|
|
end
|
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
end
|