2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/yaml"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/yaml"
|
2015-09-21 07:51:54 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::YAML" do
|
|
|
|
describe "when loading a valid yaml" do
|
2019-05-31 21:59:06 +00:00
|
|
|
let(:resource) { load_resource("yaml", "kitchen.yml") }
|
2015-10-27 14:41:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "gets params as a hashmap" do
|
2015-10-27 14:41:43 +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
|
2015-10-27 14:41:43 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves params by name" do
|
|
|
|
_(resource.send("name")).must_equal "vagrant"
|
2015-10-27 14:41:43 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "retrieves an array by name" do
|
|
|
|
_(resource.send("platforms")).must_equal %w{linux mac}
|
2015-10-27 14:41:43 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "doesnt resolve dot-notation names" do
|
|
|
|
_(resource.send("driver.customize.memory")).must_be_nil
|
2015-10-27 14:41:43 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "doesnt resolve symbol-notation names" do
|
2015-10-27 14:41:43 +00:00
|
|
|
_(resource.send(:'driver.customize.memory')).must_be_nil
|
|
|
|
end
|
2017-10-06 17:24:31 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "supports fetching by symbol keys" do
|
2017-10-06 17:24:31 +00:00
|
|
|
_(resource.send(:symbol_key)).must_equal 123
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "support fetching by symbol keys in array syntax for rspec-its" do
|
|
|
|
_(resource.send(:[], :symbol_key_deep, "foo")).must_equal "bar"
|
2017-10-06 17:24:31 +00:00
|
|
|
end
|
2015-09-21 07:51:54 +00:00
|
|
|
end
|
|
|
|
end
|