Question: How to load attributes from a file to chefspec node

Question

How to load attributes from a file to chefspec node

Answers 1
Added at 2017-07-28 15:07
Tags
Question

I have the following layout:

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

In the attributes files I have a lot of common settings likes

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

I would like to use them in my chefspec, like

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

How can I include this file to my node from SoloRunner/ServerRunner?

Answers to

How to load attributes from a file to chefspec node

nr: #1 dodano: 2017-07-29 02:07

Run the .converge() first and you'll see them in there. But remember that you almost ever parameterize your tests on the same inputs on both sides, that wouldn't be a useful test since it doesn't check if the value is what you expected it to be.

Source Show
◀ Wstecz