Skip to content

Instantly share code, notes, and snippets.

@gsarjeant
Created October 18, 2014 01:29
Show Gist options
  • Save gsarjeant/a2807aba13f2cd326ee4 to your computer and use it in GitHub Desktop.
Save gsarjeant/a2807aba13f2cd326ee4 to your computer and use it in GitHub Desktop.
Puppet manifest shared group
require 'spec_helper_acceptance'
# Defines a shared example group for solution manifests.
# Pass a manifest to this shared example group by declaring let(:manifest) { some_manifest }
# in the it_behaves_like "a puppet manifest" block in your test.
shared_examples_for "a puppet manifest" do
describe 'on first application' do
it 'should have empty stderr' do
apply_manifest(manifest, :catch_failures => true) do |r|
expect(r.stderr).to eq("")
end
end
end
describe 'on second application' do
# I'm not thrilled about this composite test, but can't figure out
# how to break it up while passing in a manifest to use with apply_manifest.
it 'should have empty stderr and zero exit code' do
apply_manifest(manifest, :catch_failures => true) do |r|
expect(r.stderr).to eq("")
expect(r.exit_code).to be_zero
end
end
end
end
@gsarjeant
Copy link
Author

Note that this probably won't work for puppet manifests that export resources. It makes the following assumptions:

  • The initial application of the manifest will succeed, and will change something on the target system
  • The second application will succeed and will make no changes (because the first application already handled that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment