summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lawrence <dannyla@linux.com>2014-07-27 19:42:03 +1000
committerDaniel Lawrence <dannyla@linux.com>2014-07-27 19:42:03 +1000
commit6bd87535749c11d3a519677b9a6c88b4330e962b (patch)
tree3a24c47cb76fd00a72f46db7464e5be876e6ecc5
parent1eae2fb2781895a7db58cf23cc448e7d5212cbe6 (diff)
started adding spec tests
-rw-r--r--.fixtures.yml6
-rw-r--r--Rakefile2
-rw-r--r--spec/classes/python_spec.rb70
-rw-r--r--spec_helper.rb25
4 files changed, 103 insertions, 0 deletions
diff --git a/.fixtures.yml b/.fixtures.yml
new file mode 100644
index 0000000..6dcef97
--- /dev/null
+++ b/.fixtures.yml
@@ -0,0 +1,6 @@
+ fixtures:
+ repositories:
+ stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
+# concat: "git://github.com/puppetlabs/puppetlabs-concat.git"
+ symlinks:
+ python: "#{source_dir}" \ No newline at end of file
diff --git a/Rakefile b/Rakefile
index 58df3ec..b133dff 100644
--- a/Rakefile
+++ b/Rakefile
@@ -6,3 +6,5 @@ PuppetLint.configuration.with_filename = true
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_80chars')
+
+require 'puppetlabs_spec_helper/rake_tasks'
diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb
new file mode 100644
index 0000000..af94b70
--- /dev/null
+++ b/spec/classes/python_spec.rb
@@ -0,0 +1,70 @@
+require_relative '../../spec_helper'
+
+describe 'python', :type => :class do
+ context "on Debian OS" do
+ let :facts do
+ {
+ :id => 'root',
+ :kernel => 'Linux',
+ :lsbdistcodename => 'squeeze',
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ :operatingsystemrelease => '6',
+ :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ :concat_basedir => '/dne',
+ }
+ end
+
+ it { is_expected.to contain_class("python::install") }
+ # Base debian packages.
+ it { is_expected.to contain_package("python") }
+ it { is_expected.to contain_package("python-dev") }
+ it { is_expected.to contain_package("python-pip") }
+ # Basic python packages (from pip)
+ it { is_expected.to contain_package("python-virtualenv")}
+
+ describe "with manage_gunicorn" do
+ context "true" do
+ let (:params) {{ :manage_gunicorn => true }}
+ it { is_expected.to contain_package("gunicorn") }
+ end
+ end
+ describe "with manage_gunicorn" do
+ context "empty args" do
+ #let (:params) {{ :manage_gunicorn => '' }}
+ it { is_expected.to contain_package("gunicorn") }
+ end
+ end
+
+ describe "without mange_gunicorn" do
+ context "false" do
+ let (:params) {{ :manage_gunicorn => false }}
+ it {is_expected.not_to contain_package("gunicorn")}
+ end
+ end
+
+ end
+
+ context "on a Redhat 5 OS" do
+ let :facts do
+ {
+ :id => 'root',
+ :kernel => 'Linux',
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RedHat',
+ :operatingsystemrelease => '5',
+ :concat_basedir => '/dne',
+ :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ }
+ end
+ it { is_expected.to contain_class("python::install") }
+ # Base debian packages.
+ it { is_expected.to contain_package("python") }
+ it { is_expected.to contain_package("python-devel") }
+ it { is_expected.to contain_package("python-pip") }
+ # Basic python packages (from pip)
+ it { is_expected.to contain_package("python-virtualenv")}
+
+ end
+
+end
diff --git a/spec_helper.rb b/spec_helper.rb
new file mode 100644
index 0000000..65379ee
--- /dev/null
+++ b/spec_helper.rb
@@ -0,0 +1,25 @@
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+RSpec.configure do |c|
+ c.treat_symbols_as_metadata_keys_with_true_values = true
+
+ c.before :each do
+ # Ensure that we don't accidentally cache facts and environment
+ # between test cases.
+ Facter::Util::Loader.any_instance.stubs(:load_all)
+ Facter.clear
+ Facter.clear_messages
+
+ # Store any environment variables away to be restored later
+ @old_env = {}
+ ENV.each_key {|k| @old_env[k] = ENV[k]}
+
+ if ENV['STRICT_VARIABLES'] == 'yes'
+ Puppet.settings[:strict_variables]=true
+ end
+ end
+end
+
+shared_examples :compile, :compile => true do
+ it { should compile.with_all_deps }
+end