Skip to content

Commit 6bd8753

Browse files
started adding spec tests
1 parent 1eae2fb commit 6bd8753

4 files changed

Lines changed: 103 additions & 0 deletions

File tree

.fixtures.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fixtures:
2+
repositories:
3+
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
4+
# concat: "git://github.com/puppetlabs/puppetlabs-concat.git"
5+
symlinks:
6+
python: "#{source_dir}"

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ PuppetLint.configuration.with_filename = true
66
PuppetLint.configuration.send('disable_documentation')
77
PuppetLint.configuration.send('disable_class_parameter_defaults')
88
PuppetLint.configuration.send('disable_80chars')
9+
10+
require 'puppetlabs_spec_helper/rake_tasks'

spec/classes/python_spec.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
require_relative '../../spec_helper'
2+
3+
describe 'python', :type => :class do
4+
context "on Debian OS" do
5+
let :facts do
6+
{
7+
:id => 'root',
8+
:kernel => 'Linux',
9+
:lsbdistcodename => 'squeeze',
10+
:osfamily => 'Debian',
11+
:operatingsystem => 'Debian',
12+
:operatingsystemrelease => '6',
13+
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
14+
:concat_basedir => '/dne',
15+
}
16+
end
17+
18+
it { is_expected.to contain_class("python::install") }
19+
# Base debian packages.
20+
it { is_expected.to contain_package("python") }
21+
it { is_expected.to contain_package("python-dev") }
22+
it { is_expected.to contain_package("python-pip") }
23+
# Basic python packages (from pip)
24+
it { is_expected.to contain_package("python-virtualenv")}
25+
26+
describe "with manage_gunicorn" do
27+
context "true" do
28+
let (:params) {{ :manage_gunicorn => true }}
29+
it { is_expected.to contain_package("gunicorn") }
30+
end
31+
end
32+
describe "with manage_gunicorn" do
33+
context "empty args" do
34+
#let (:params) {{ :manage_gunicorn => '' }}
35+
it { is_expected.to contain_package("gunicorn") }
36+
end
37+
end
38+
39+
describe "without mange_gunicorn" do
40+
context "false" do
41+
let (:params) {{ :manage_gunicorn => false }}
42+
it {is_expected.not_to contain_package("gunicorn")}
43+
end
44+
end
45+
46+
end
47+
48+
context "on a Redhat 5 OS" do
49+
let :facts do
50+
{
51+
:id => 'root',
52+
:kernel => 'Linux',
53+
:osfamily => 'RedHat',
54+
:operatingsystem => 'RedHat',
55+
:operatingsystemrelease => '5',
56+
:concat_basedir => '/dne',
57+
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
58+
}
59+
end
60+
it { is_expected.to contain_class("python::install") }
61+
# Base debian packages.
62+
it { is_expected.to contain_package("python") }
63+
it { is_expected.to contain_package("python-devel") }
64+
it { is_expected.to contain_package("python-pip") }
65+
# Basic python packages (from pip)
66+
it { is_expected.to contain_package("python-virtualenv")}
67+
68+
end
69+
70+
end

spec_helper.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'puppetlabs_spec_helper/module_spec_helper'
2+
3+
RSpec.configure do |c|
4+
c.treat_symbols_as_metadata_keys_with_true_values = true
5+
6+
c.before :each do
7+
# Ensure that we don't accidentally cache facts and environment
8+
# between test cases.
9+
Facter::Util::Loader.any_instance.stubs(:load_all)
10+
Facter.clear
11+
Facter.clear_messages
12+
13+
# Store any environment variables away to be restored later
14+
@old_env = {}
15+
ENV.each_key {|k| @old_env[k] = ENV[k]}
16+
17+
if ENV['STRICT_VARIABLES'] == 'yes'
18+
Puppet.settings[:strict_variables]=true
19+
end
20+
end
21+
end
22+
23+
shared_examples :compile, :compile => true do
24+
it { should compile.with_all_deps }
25+
end

0 commit comments

Comments
 (0)