So, I am trying to add some unit test to my recipe.
Testing something that has an action is easy. But when your action is :nothing because it gets triggered by a notification then it sucks. The following block gets called with: notifies :create, 'directory[Create my directory]', :immediately
directory 'Create my directory' do
path myPath
mode '0755'
owner 'me'
group 'aGroup'
action :nothing
notifies :create_if_missing, 'remote_file[Download artifact]', :immediately
notifies :run, 'execute[unpack artifact]', :immediately
end
When before the action was :create the unit test was simple
it 'Test create directory' do
expect(chef_run).to create_directory('Create my directory')
.with_path('myPath')
.with_mode('0755')
.with_owner('me')
.with_group('aGroup')
end
so how do you test something when it receives a notification?