所以,我正在尝试在我的食谱中添加一些单元测试。
测试有动作的东西很容易。但是,当您的操作是 :nothing 因为它是由通知触发时,那就糟透了。调用以下块: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
在操作之前:创建单元测试很简单
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
那么当它收到通知时你如何测试它呢?