I created a chef resource that "extends" the chef's deployment resource. The main idea is to check for the existence of a file deploy/crontabsimilar to the mechanisms deploy/after_restart.rbin the source that will be deployed and create cronjobs from it.
Although this mechanism works as it should (see https://github.com/fh/easybib-cookbooks/blob/t/cron-tests/easybib/providers/deploy.rb#L11-L14 ), I'm struggling with ChefSpec based testing. I am currently trying to create mocks with FakeFS- but when I make fun of the file system before running Chef, the launch fails because cookies are not found because they do not exist on the manufactured file system. If I do not, then the finished file is deploy/crontabclearly not found, so the provider does nothing. My current approach is to call FakeFS.activate!immediately before runner.converge(described_recipe)in chef_run.
I would like to hear some recommendations on how to do the right test here: is it possible that it is possible to enable FakeFS just before deploying the resource or partially mock the file system?
source
share