I would like to use chefspec to test the idempotency of my recipe.
Let's say I have a recipe that includes these two resource statements:
file '/etc/app.config' do
action :create
notifies :restart, "service[app]"
end
service 'app' do
action :enable
end
How can I write a chefspec example that proves, given the file /etc/app.config
already exists, then the app
service will not be notified to restart?
Is there some mocking I can do so the 'file' resource thinks the file already exists? Can I run the ChefSpec::ServerRunner twice, keeping the state from the first run (I assume not, since the file won't have really been created)? Or will I be forced to use test-kitchen and Vagrant to make things happen for realz?
(Note: My actual cookbook has a custom LWRP that builds the configuration file. It gets info from a chef-server, which is why I'm using ServerRunner)