-
-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from maestrodev/specs
Add specs using puppetlabs_spec_helper and librarian-puppet
- Loading branch information
Showing
10 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fixtures: | ||
symlinks: | ||
nginx: "#{source_dir}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
files/server_test.crt | ||
files/server_test.pem | ||
pkg/ | ||
.librarian/ | ||
.tmp/ | ||
pkg/ | ||
spec/fixtures/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source 'https://rubygems.org' | ||
|
||
group :rake do | ||
gem 'puppet', '>=3.0.1' | ||
gem 'rspec-puppet', '>=0.1.3' | ||
gem 'rake', '>=0.9.2.2' | ||
gem 'puppet-lint', '>=0.1.12' | ||
gem 'puppetlabs_spec_helper' | ||
gem 'puppet-blacksmith' | ||
gem 'librarian-puppet-maestrodev' | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
diff-lcs (1.2.4) | ||
facter (1.7.1) | ||
hiera (1.2.1) | ||
json_pure | ||
highline (1.6.19) | ||
json (1.8.0) | ||
json_pure (1.8.0) | ||
librarian (0.1.0) | ||
highline | ||
thor (~> 0.15) | ||
librarian-puppet-maestrodev (0.9.9.2) | ||
json | ||
librarian (>= 0.1.0) | ||
thor (~> 0.15) | ||
metaclass (0.0.1) | ||
mime-types (1.23) | ||
mocha (0.14.0) | ||
metaclass (~> 0.0.1) | ||
nokogiri (1.5.9) | ||
puppet (3.2.1) | ||
facter (~> 1.6) | ||
hiera (~> 1.0) | ||
rgen (~> 0.6) | ||
puppet-blacksmith (1.0.5) | ||
nokogiri | ||
puppet (>= 2.7.16) | ||
puppetlabs_spec_helper (>= 0.3.0) | ||
rake | ||
rest-client | ||
puppet-lint (0.3.2) | ||
puppetlabs_spec_helper (0.4.1) | ||
mocha (>= 0.10.5) | ||
rake | ||
rspec (>= 2.9.0) | ||
rspec-puppet (>= 0.1.1) | ||
rake (10.0.4) | ||
rest-client (1.6.7) | ||
mime-types (>= 1.16) | ||
rgen (0.6.2) | ||
rspec (2.13.0) | ||
rspec-core (~> 2.13.0) | ||
rspec-expectations (~> 2.13.0) | ||
rspec-mocks (~> 2.13.0) | ||
rspec-core (2.13.1) | ||
rspec-expectations (2.13.0) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.13.1) | ||
rspec-puppet (0.1.6) | ||
rspec | ||
thor (0.18.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
librarian-puppet-maestrodev | ||
puppet (>= 3.0.1) | ||
puppet-blacksmith | ||
puppet-lint (>= 0.1.12) | ||
puppetlabs_spec_helper | ||
rake (>= 0.9.2.2) | ||
rspec-puppet (>= 0.1.3) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
forge 'http://forge.puppetlabs.com' | ||
|
||
mod 'puppetlabs/stdlib', '>=0.1.6' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FORGE | ||
remote: http://forge.puppetlabs.com | ||
specs: | ||
puppetlabs/stdlib (4.1.0) | ||
|
||
DEPENDENCIES | ||
puppetlabs/stdlib (>= 0.1.6) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'bundler' | ||
Bundler.require(:rake) | ||
require 'rake/clean' | ||
|
||
CLEAN.include('spec/fixtures/', 'doc', 'pkg') | ||
CLOBBER.include('.tmp', '.librarian') | ||
|
||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet_blacksmith/rake_tasks' | ||
|
||
# use librarian-puppet to manage fixtures instead of .fixtures.yml | ||
# offers more possibilities like explicit version management, forge downloads,... | ||
task :librarian_spec_prep do | ||
sh "librarian-puppet install --path=spec/fixtures/modules/" | ||
end | ||
task :spec_prep => :librarian_spec_prep | ||
|
||
task :default => [:clean, :spec] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nginx' do | ||
|
||
shared_examples 'linux' do |operatingsystem, user| | ||
let(:facts) {{ :kernel => 'linux', :operatingsystem => operatingsystem }} | ||
|
||
it { should contain_service('nginx').with( | ||
:ensure => 'running', | ||
:enable => true | ||
) } | ||
|
||
it { should contain_file('/var/nginx/client_body_temp').with_owner(user) } | ||
end | ||
|
||
|
||
context 'redhat' do | ||
it_behaves_like 'linux', 'redhat', 'nginx' | ||
end | ||
|
||
context 'debian' do | ||
it_behaves_like 'linux', 'debian', 'www-data' | ||
end | ||
|
||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nginx::package' do | ||
|
||
shared_examples 'redhat' do |operatingsystem| | ||
let(:facts) {{ :operatingsystem => operatingsystem }} | ||
it { should contain_package('nginx') } | ||
it { should contain_package('GeoIP') } | ||
it { should contain_package('gd') } | ||
it { should contain_package('libXpm') } | ||
it { should contain_package('libxslt') } | ||
it { should contain_yumrepo('nginx-release').with_enabled('1') } | ||
end | ||
|
||
shared_examples 'debian' do |operatingsystem| | ||
let(:facts) {{ :operatingsystem => operatingsystem }} | ||
it { should contain_file('/etc/apt/sources.list.d/nginx.list') } | ||
end | ||
|
||
shared_examples 'suse' do |operatingsystem| | ||
let(:facts) {{ :operatingsystem => operatingsystem }} | ||
it { should contain_package('nginx-0.8') } | ||
it { should contain_package('apache2') } | ||
it { should contain_package('apache2-itk') } | ||
it { should contain_package('apache2-utils') } | ||
it { should contain_package('gd') } | ||
end | ||
|
||
|
||
context 'RedHat' do | ||
it_behaves_like 'redhat', 'centos' | ||
it_behaves_like 'redhat', 'fedora' | ||
it_behaves_like 'redhat', 'rhel' | ||
it_behaves_like 'redhat', 'redhat' | ||
it_behaves_like 'redhat', 'scientific' | ||
end | ||
|
||
context 'amazon' do | ||
let(:facts) {{ :operatingsystem => 'amazon' }} | ||
it { should contain_package('nginx') } | ||
end | ||
|
||
context 'debian' do | ||
it_behaves_like 'debian', 'debian' | ||
it_behaves_like 'debian', 'ubuntu' | ||
end | ||
|
||
context 'suse' do | ||
it_behaves_like 'suse', 'opensuse' | ||
it_behaves_like 'suse', 'suse' | ||
end | ||
|
||
context 'other' do | ||
let(:facts) {{ :operatingsystem => 'xxx' }} | ||
it { expect { subject }.to raise_error(Puppet::Error, /Module nginx is not supported on xxx/) } | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'puppetlabs_spec_helper/module_spec_helper' |