aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAdam Jahn <ajjahn@gmail.com>2015-04-11 16:42:26 -0400
committerAdam Jahn <ajjahn@gmail.com>2015-04-11 16:42:26 -0400
commit109024fd916b67aebf983427bde8b8761a8d2a97 (patch)
tree520c854fb196a48cbf5c1757546e235e5d9772ef /spec
parent111bb7e83fd75f5c7e116d4d67e8c0a0eb627b17 (diff)
downloadpuppet-samba-109024fd916b67aebf983427bde8b8761a8d2a97.tar.gz
puppet-samba-109024fd916b67aebf983427bde8b8761a8d2a97.tar.bz2
first set of specs
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/samba__server__config_spec.rb10
-rw-r--r--spec/classes/samba__server__install_spec.rb9
-rw-r--r--spec/classes/samba__server__service_spec.rb40
-rw-r--r--spec/classes/samba__server_spec.rb9
-rw-r--r--spec/fixtures/manifests/init.pp7
-rw-r--r--spec/spec_helper.rb8
6 files changed, 83 insertions, 0 deletions
diff --git a/spec/classes/samba__server__config_spec.rb b/spec/classes/samba__server__config_spec.rb
new file mode 100644
index 0000000..5f13aa4
--- /dev/null
+++ b/spec/classes/samba__server__config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe 'samba::server::config', :type => :class do
+ context "on a Debian OS" do
+ let( :facts ) { { :osfamily => 'Debian' } }
+
+ it { should contain_file('/etc/samba/smb.conf').with_owner('root') }
+ end
+end
+
diff --git a/spec/classes/samba__server__install_spec.rb b/spec/classes/samba__server__install_spec.rb
new file mode 100644
index 0000000..9764687
--- /dev/null
+++ b/spec/classes/samba__server__install_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe 'samba::server::install', :type => :class do
+ context "on a Debian OS" do
+ let(:facts) {{ :osfamily => 'Debian' }}
+ it { should contain_package('samba') }
+ end
+end
+
diff --git a/spec/classes/samba__server__service_spec.rb b/spec/classes/samba__server__service_spec.rb
new file mode 100644
index 0000000..bc28a9b
--- /dev/null
+++ b/spec/classes/samba__server__service_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'samba::server::service' do
+ context 'on a Debian os family' do
+ let(:facts) {{ :osfamily => 'Debian' }}
+
+ it { should contain_service('samba')
+ .with_require('Class[Samba::Server::Config]') }
+
+ context 'Debian' do
+ let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Debian' }}
+ it { should contain_service('samba') }
+ end
+
+ context 'Ubuntu' do
+ let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Ubuntu' }}
+ it { should contain_service('smbd') }
+ end
+ end
+
+ context 'on a Redhat os family' do
+ let(:facts) {{ :osfamily => 'Redhat' }}
+ it { should contain_service('smb') }
+ end
+
+ context 'on a Archlinux os family' do
+ let(:facts) {{ :osfamily => 'Archlinux' }}
+ it { should contain_service('smbd') }
+ end
+
+ context 'on a Gentoo os family' do
+ let(:facts) {{ :osfamily => 'Linux', :operatingsystem => 'Gentoo' }}
+ it { should contain_service('samba') }
+ end
+
+ context 'on an unsupported OS' do
+ let(:facts) {{ :osfamily => 'Solaris' }}
+ it { should raise_error(/Solaris is not supported by this module./) }
+ end
+end
diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb
new file mode 100644
index 0000000..89d994f
--- /dev/null
+++ b/spec/classes/samba__server_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe 'samba::server' do
+ let(:facts) {{ :osfamily => 'Debian' }}
+
+ it { should contain_class('samba::server::install') }
+ it { should contain_class('samba::server::config') }
+ it { should contain_class('samba::server::service') }
+end
diff --git a/spec/fixtures/manifests/init.pp b/spec/fixtures/manifests/init.pp
new file mode 100644
index 0000000..0f64360
--- /dev/null
+++ b/spec/fixtures/manifests/init.pp
@@ -0,0 +1,7 @@
+node 'testhost.example.com' {
+
+ include samba::server
+
+}
+
+node default {}
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..81f98ac
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,8 @@
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+RSpec.configure do |c|
+ c.before do
+ # avoid "Only root can execute commands as other users"
+ Puppet.features.stubs(:root? => true)
+ end
+end