postfix-cookbook/spec/wrapper_spec.rb
Matthieu Vachon 3445567364 Using node.default_unless instead of node.default in _attributes
* Wrapper cookbook usually uses default level to override attributes
   of the wrapped cookbook. Here, we had a problem because if the
   wrapper cookbook was enabling sasl and was setting a relayhost
   and a user/password combination using the default level, this was
   not working because _attributes resets those attributes.

   To fix this, we now use node.default_unless which will set the
   attribute only if it's not already set ensuring that wrapper
   cookbook overriden attributes using default level are correctly
   kept when computing derived attributes.
2015-08-27 17:17:30 -04:00

21 lines
639 B
Ruby

require 'spec_helper'
##
# Spec to ensure wrapper cookbook can correctly override
# attributes using default level without _attributes
# recipe clearing them.
describe 'wrapper::default' do
cached(:chef_run) do
ChefSpec::SoloRunner.new.converge(described_recipe)
end
describe '_attributes recipes' do
it 'keeps wrapper cookbook default set attributes' do
expect(chef_run.node['postfix']['main']['relayhost']).to eq('please')
expect(chef_run.node['postfix']['main']['smtp_sasl_security_options']).to eq('keep')
expect(chef_run.node['postfix']['sasl']['smtp_sasl_user_name']).to eq('us')
end
end
end