Created
January 15, 2015 19:53
-
-
Save petems/d686a656a43e18cc7db4 to your computer and use it in GitHub Desktop.
Mocking validate_cmd in Puppet
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 'spec_helper' | |
describe 'sudo::sudoers', :type => :define do | |
let(:title) { 'world.domination' } | |
if (Puppet.version >= '3.5.0') | |
context "validating content with puppet #{Puppet.version}" do | |
let(:params) { { :users => ['joe'] } } | |
let(:facts) {{ :puppetversion => Puppet.version }} | |
it { | |
should contain_file('/etc/sudoers.d/world_domination').with_validate_cmd('/usr/sbin/visudo -c -f %') | |
} | |
end | |
else | |
context "validating content with puppet #{Puppet.version}" do | |
let(:params) { { :users => ['joe'] } } | |
let(:facts) {{ :puppetversion => Puppet.version }} | |
it { | |
allow(Puppet::Util::Execution).to receive(:execute).with("/usr/sbin/visudo -c -f %"). | |
and_return 1 | |
should contain_file('/etc/sudoers.d/world_domination').with_validate_cmd(nil) | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment