Created
July 24, 2015 07:12
-
-
Save joerg/19dd03dd20d31ee5409d to your computer and use it in GitHub Desktop.
chefspec-notify-error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execute 'Notifier' do | |
command 'touch /tmp/notifier' | |
only_if 'test_condition_command' | |
notifies :touch, 'file[/tmp/notified]', :immediately | |
end | |
file '/tmp/notified' do | |
action :nothing | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'chefspec' | |
describe 'chefspec-notifiy::default' do | |
let(:chef_run) do | |
ChefSpec::SoloRunner.converge(described_recipe) | |
end | |
context 'test_condition_command returns true and' do | |
before do | |
stub_command('test_condition_command').and_return(true) | |
end | |
it 'runs execute notifier' do | |
expect(chef_run).to run_execute('Notifier') | |
end | |
it 'notifies file /tmp/notified to be created' do | |
expect(chef_run.execute('Notifier')).to notify('file[/tmp/notified]').to(:touch).immediately | |
end | |
it 'touches file /tmp/notified' do | |
expect(chef_run).to touch_file('/tmp/notified') # <- Does not work! | |
end | |
end | |
context 'test_condition_command returns false and' do | |
before do | |
stub_command('test_condition_command').and_return(false) | |
end | |
it 'does not run execute notifier' do | |
expect(chef_run).to_not run_execute('Notifier') | |
end | |
it 'does not notify file /tmp/notified' do | |
expect(chef_run.execute('Notifier')).to_not notify('file[/tmp/notified]').to(:touch) # <- Does not work | |
end | |
it 'does not touch file /tmp/notified' do | |
expect(chef_run).to_not touch_file('/tmp/notified') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment