2017-04-25 45 views
0

所以,我想在我的食譜中添加一些單元測試。測試沒有動作並接收到通知的塊嗎?

測試有動作的東西很容易。 但是當你的行動是:什麼都不是,因爲它被通知觸發,然後它很糟糕。 以下塊被調用: 通知:創建「目錄[創建我的目錄]」,:立即

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 

那麼如何在收到通知時測試一些東西?

回答

0

評論action :nothing,進行廚房測試運行並查看結果。測試結束後,不要忘記取消註釋。

相關問題