logrotate_app 'nginx' do
cookbook 'logrotate'
path [
"#{node['web']['root']}/logs/ssl-access.log",
"#{node['web']['root']}/logs/ssl-error.log"
]
...
end
In older versions when coerce was not used, one could simply write the following chef spec:
it 'add logrotation' do
expect(chef_run).to enable_logrotate_app('nginx').with(
path: [
"/path/to/www/logs/ssl-access.log",
"/path/to/www/logs/ssl-error.log",
],
...
)
end
As coerce merges the array on assignment, this does not work anymore.
The workaround is to "deal with the internals" and format the paths as a coerced string like
it 'add logrotation' do
expect(chef_run).to enable_logrotate_app('nginx').with(
path: '"/path/to/www/logs/ssl-access.log" "/path/to/www/logs/ssl-error.log"',
...
)
end
which is obviously ugly and does not represent the way, the resource is called in the recipe. Any idea to make this usable again?
With the 3.0.0 changes introdoced in https://github.com/sous-chefs/logrotate/commit/dc20786df1b23734379aaaf7cde03dfbcb4c96e7#diff-b7e94f5fcd66051355907f23b26ff6ac96685ca36c95837931a588074999fbf9R26 it's a lot harder to write chefspecs when a
logrotate_app
resource is called with an paths arraye.g.
In older versions when
coerce
was not used, one could simply write the following chef spec:As
coerce
merges the array on assignment, this does not work anymore. The workaround is to "deal with the internals" and format the paths as a coerced string likewhich is obviously ugly and does not represent the way, the resource is called in the recipe. Any idea to make this usable again?
Thank you.