如何将文件中的属性加载到chefspec节点

时间:2017-07-28 13:23:24

标签: ruby rspec chef chefspec

我有以下布局:

attributes/default.rb
recipes/my_recipe.rb
spec/unit/recipes/my_recipe_spec.rb

在属性文件中,我有许多常见设置,如

default['framework']['folder']['lib'] = '/usr/lib/fwrk'

我想在我的chefspec中使用它们,比如

it 'install the lib if there are changes' do
    lib_path = chef_run.node['framework']['folder']['lib']
    puts(lib_path)
end

如何从SoloRunner / ServerRunner将此文件包含到我的节点?

1 个答案:

答案 0 :(得分:1)

首先运行.converge(),然后您就会在那里看到它们。但请记住,您几乎都要在双方的相同输入上对测试进行参数化,这不是一个有用的测试,因为它不会检查该值是否符合您的预期。