Add the machinery necessary to run rspec-puppet tests against these modules

This is largely cribbed from jenkins-infra RSpec tooling which can be found in
    <https://github.com/jenkins-infra/jenkins-infra/spec>

For more information about how to use rspec-puppet see: <http://rspec-puppet.com/>
This commit is contained in:
R. Tyler Croy 2014-12-31 13:55:11 -08:00
parent 9383865893
commit 504983705a
6 changed files with 44 additions and 0 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@ ssl/
# Other files and folders
.settings/
.project
*.sw*
.ruby-*
.bundle
Gemfile.lock

1
.rspec Normal file
View File

@ -0,0 +1 @@
--order random --format progress --fail-fast --color

View File

@ -3,3 +3,9 @@ source "https://rubygems.org"
gem 'r10k'
gem 'hiera-eyaml'
gem 'hiera-eyaml-gpg'
gem 'rspec', '~> 2.99'
gem 'rspec-puppet'
gem 'puppet', '~> 3.6.0'
gem 'puppetlabs_spec_helper', :github => 'jenkins-infra/puppetlabs_spec_helper'
gem 'serverspec'

View File

@ -0,0 +1,13 @@
require 'spec_helper'
describe 'orthrus' do
context 'on ubuntu' do
let(:facts) do
{
:asfosname => 'ubuntu',
}
end
it { should contain_package 'orthrus' }
end
end

1
spec/fixtures/site.pp vendored Normal file
View File

@ -0,0 +1 @@
node default { }

21
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,21 @@
require 'rubygems'
require 'rspec'
require 'puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
RSpec.configure do |c|
c.mock_with :rspec
c.module_path = File.expand_path(File.dirname(__FILE__) + '/../modules')
c.manifest = File.expand_path(File.dirname(__FILE__) + '/fixtures/site.pp')
c.default_facts = {
:kernel => 'Linux',
}
c.before(:each) do
# Workaround until this is fixed:
# <https://tickets.puppetlabs.com/browse/PUP-1547>
require 'puppet/confine/exists'
Puppet::Confine::Exists.any_instance.stubs(:which => '')
end
end