summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/munin_client_spec.rb50
-rw-r--r--spec/classes/munin_host_spec.rb37
-rw-r--r--spec/spec.opts1
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/spec_helper_system.rb27
5 files changed, 103 insertions, 16 deletions
diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb
index 5438b20..9a92cef 100644
--- a/spec/classes/munin_client_spec.rb
+++ b/spec/classes/munin_client_spec.rb
@@ -1,14 +1,50 @@
require 'spec_helper'
describe 'munin::client' do
- let :facts do
- {
- :operatingsystem => 'CentOS',
- :interfaces => 'lo,eth0',
- }
+ shared_examples 'debian-client' do |os, codename|
+ let(:facts) {{
+ :operatingsystem => os,
+ :osfamily => 'Debian',
+ :lsbdistcodename => codename,
+ }}
+ it { should contain_package('munin-node') }
+ it { should contain_package('iproute') }
+ it { should contain_file('/etc/munin/munin-node.conf') }
+ it { should include_class('munin::client::debian') }
+ end
+
+ shared_examples 'redhat-client' do |os, codename|
+ let(:facts) {{
+ :operatingsystem => os,
+ :osfamily => 'RedHat',
+ :lsbdistcodename => codename,
+ }}
+ it { should contain_package('munin-node') }
+ it { should contain_file('/etc/munin/munin-node.conf') }
+ end
+
+ context 'on debian-like system' do
+ it_behaves_like 'debian-client', 'Debian', 'squeeze'
+ it_behaves_like 'debian-client', 'Debian', 'wheezy'
+ it_behaves_like 'debian-client', 'Ubuntu', 'precise'
end
- it 'should compile' do
- should include_class('munin::client')
+ context 'on redhat-like system' do
+ it_behaves_like 'redhat-client', 'CentOS', '6'
+ # not supported yet
+ # it_behaves_like 'redhat', 'RedHat', '6'
end
+
+ context 'gentoo' do
+ let(:facts) {{
+ :operatingsystem => 'Gentoo',
+ :osfamily => 'Gentoo',
+ :lsbdistcodename => '',
+ :interfaces => 'lo,eth0',
+ }}
+ it { should contain_package('munin-node') }
+ it { should contain_file('/etc/munin/munin-node.conf') }
+ it { should include_class('munin::client::gentoo') }
+ end
+
end
diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb
index 2216cc5..461ced5 100644
--- a/spec/classes/munin_host_spec.rb
+++ b/spec/classes/munin_host_spec.rb
@@ -1,14 +1,37 @@
require 'spec_helper'
describe 'munin::host' do
- let :facts do
- {
- :operatingsystem => 'CentOS',
- :interfaces => 'lo,eth0',
- }
+ shared_examples 'debian-host' do |os, codename|
+ let(:facts) {{
+ :operatingsystem => os,
+ :osfamily => 'Debian',
+ :lsbdistcodename => codename,
+ :concat_basedir => '/var/lib/puppet/concat',
+ }}
+ it { should contain_package('munin') }
+ it { should contain_file('/etc/munin/munin.conf') }
+ it { should include_class('munin::host') }
end
- it 'should compile' do
- should include_class('munin::host')
+ shared_examples 'redhat-host' do |os, codename|
+ let(:facts) {{
+ :operatingsystem => os,
+ :osfamily => 'RedHat',
+ :lsbdistcodename => codename,
+ :concat_basedir => '/var/lib/puppet/concat',
+ }}
+ it { should contain_package('munin') }
+ it { should contain_file('/etc/munin/munin.conf') }
+ it { should include_class('munin::host') }
+ end
+
+ context 'on debian-like system' do
+ it_behaves_like 'debian-host', 'Debian', 'squeeze'
+ it_behaves_like 'debian-host', 'Debian', 'wheezy'
+ it_behaves_like 'debian-host', 'Ubuntu', 'precise'
+ end
+
+ context 'on redhat-like system' do
+ it_behaves_like 'redhat-host', 'CentOS', '6'
end
end
diff --git a/spec/spec.opts b/spec/spec.opts
deleted file mode 100644
index d1bd681..0000000
--- a/spec/spec.opts
+++ /dev/null
@@ -1 +0,0 @@
---format documentation --colour --backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index cffe80c..70ab1fb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -5,5 +5,7 @@ fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
- c.mock_with :mocha
end
+
+Puppet::Util::Log.level = :warning
+Puppet::Util::Log.newdestination(:console)
diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb
new file mode 100644
index 0000000..9adfea9
--- /dev/null
+++ b/spec/spec_helper_system.rb
@@ -0,0 +1,27 @@
+require 'rspec-system/spec_helper'
+require 'rspec-system-puppet/helpers'
+require 'rspec-system-serverspec/helpers'
+include Serverspec::Helper::RSpecSystem
+include Serverspec::Helper::DetectOS
+include RSpecSystemPuppet::Helpers
+
+RSpec.configure do |c|
+ # Project root
+ proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+ # Enable colour
+ c.tty = true
+
+ c.include RSpecSystemPuppet::Helpers
+
+ # This is where we 'setup' the nodes before running our tests
+ c.before :suite do
+ # Install puppet
+ puppet_install
+
+ # Install modules and dependencies
+ puppet_module_install(:source => proj_root, :module_name => 'munin')
+ shell('puppet module install puppetlabs-stdlib')
+ shell('puppet module install puppetlabs-concat')
+ end
+end