我正在为我写的食谱编写ServerSpec测试过程。测试需要节点属性来通过厨房断言各种事物。厨师 - ServerSpec - 访问节点属性
幸运的是,解释如何做到这一点这里的指南: http://jakshi.com/blog/2014/05/12/accessing-chef-attributes-in-serverspec-tests/
我遇到的问题是,这不起作用:
attrs = attrs.deep_merge(node.override_attrs) unless node.override_attrs.empty?
但这个工程:
attrs = attrs.deep_merge(node.attributes.combined_override) unless node.attributes.combined_override.empty?
我的设置与博客中描述的完全相同。由于缺乏红宝石,浏览code没有帮助。厨师客户端版本是11.14.6和测试厨房版本是1.3.1
有人可以帮忙吗?有没有其他人有这个问题?谢谢。
更新:这里是我为了模拟这个而创建的虚拟食谱的所有属性。
cb-under-test/recipes/default.rb
<Nothing>
cb-under-test/test/fixtures/cookbooks/fake/attributes/default.rb
force_override['important_dir'] = 'test_recipe_force_override'
../env/dummy-env.json
{
"name": "dummy-env",
"description": "Dummy Env",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"override_attributes": {
"important_dir": "env_override"
}
}
添加您的测试食谱的属性文件,我们无法猜测您在哪个级别设置它们... – Tensibai
这些属性来自几个地方,包括环境。我的测试食谱中没有任何属性。 – dvlpr
无论如何,如果没有提取物,我们无法猜测您的属性定义在哪个级别(默认,正常,覆盖,其他?) – Tensibai