rspec-puppet 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rspec-puppet.rb +6 -0
- data/lib/rspec-puppet/example/class_example_group.rb +6 -1
- data/lib/rspec-puppet/example/define_example_group.rb +6 -1
- data/lib/rspec-puppet/example/function_example_group.rb +15 -5
- data/lib/rspec-puppet/example/host_example_group.rb +6 -1
- data/rspec-puppet.gemspec +1 -1
- data/spec/functions/split_spec.rb +7 -1
- metadata +33 -51
data/lib/rspec-puppet.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'puppet'
|
2
2
|
require 'rspec'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'tmpdir'
|
3
5
|
require 'rspec-puppet/matchers'
|
4
6
|
require 'rspec-puppet/example'
|
5
7
|
require 'rspec-puppet/setup'
|
6
8
|
|
9
|
+
if Integer(Puppet.version.split('.').first) >= 3
|
10
|
+
Puppet.initialize_settings
|
11
|
+
end
|
12
|
+
|
7
13
|
RSpec.configure do |c|
|
8
14
|
c.add_setting :module_path, :default => '/etc/puppet/modules'
|
9
15
|
c.add_setting :manifest_dir, :default => nil
|
@@ -8,6 +8,9 @@ module RSpec::Puppet
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def catalogue
|
11
|
+
vardir = Dir.mktmpdir
|
12
|
+
Puppet[:vardir] = vardir
|
13
|
+
Puppet[:hiera_config] = File.join(vardir, "hiera.yaml") if Puppet[:hiera_config] == File.expand_path("/dev/null")
|
11
14
|
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
12
15
|
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
|
13
16
|
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
|
@@ -49,7 +52,9 @@ module RSpec::Puppet
|
|
49
52
|
}
|
50
53
|
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
|
51
54
|
|
52
|
-
build_catalog(nodename, facts_val, code)
|
55
|
+
catalogue = build_catalog(nodename, facts_val, code)
|
56
|
+
FileUtils.rm_rf(vardir) if File.directory?(vardir)
|
57
|
+
catalogue
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
@@ -10,6 +10,9 @@ module RSpec::Puppet
|
|
10
10
|
def catalogue
|
11
11
|
define_name = self.class.top_level_description.downcase
|
12
12
|
|
13
|
+
vardir = Dir.mktmpdir
|
14
|
+
Puppet[:vardir] = vardir
|
15
|
+
Puppet[:hiera_config] = File.join(vardir, "hiera.yaml") if Puppet[:hiera_config] == File.expand_path("/dev/null")
|
13
16
|
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
14
17
|
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
|
15
18
|
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
|
@@ -51,7 +54,9 @@ module RSpec::Puppet
|
|
51
54
|
}
|
52
55
|
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
|
53
56
|
|
54
|
-
build_catalog(nodename, facts_val, code)
|
57
|
+
catalogue = build_catalog(nodename, facts_val, code)
|
58
|
+
FileUtils.rm_rf(vardir) if File.directory?(vardir)
|
59
|
+
catalogue
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
@@ -1,13 +1,15 @@
|
|
1
|
+
require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
|
2
|
+
|
1
3
|
module RSpec::Puppet
|
2
4
|
module FunctionExampleGroup
|
3
5
|
include RSpec::Puppet::FunctionMatchers
|
6
|
+
PuppetInternals = PuppetlabsSpec::PuppetInternals
|
4
7
|
|
5
8
|
def subject
|
6
9
|
function_name = self.class.top_level_description.downcase
|
7
10
|
|
8
11
|
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
9
12
|
Puppet[:libdir] = Dir["#{Puppet[:modulepath]}/*/lib"].entries.join(File::PATH_SEPARATOR)
|
10
|
-
Puppet::Parser::Functions.autoloader.loadall
|
11
13
|
|
12
14
|
# if we specify a pre_condition, we should ensure that we compile that code
|
13
15
|
# into a catalog that is accessible from the scope where the function is called
|
@@ -23,20 +25,28 @@ module RSpec::Puppet
|
|
23
25
|
# we need to get a compiler, b/c we can attach that to a scope
|
24
26
|
@compiler = build_compiler(nodename, facts_val)
|
25
27
|
else
|
26
|
-
@compiler =
|
28
|
+
@compiler = PuppetInternals.compiler
|
27
29
|
end
|
28
30
|
|
29
|
-
scope =
|
31
|
+
scope = PuppetInternals.scope(:compiler => @compiler)
|
30
32
|
|
31
|
-
|
33
|
+
# Return the method instance for the function. This can be used with
|
34
|
+
# method.call
|
35
|
+
method = PuppetInternals.function_method(function_name, :scope => scope)
|
32
36
|
end
|
33
37
|
|
34
38
|
def compiler
|
35
39
|
@compiler
|
36
40
|
end
|
41
|
+
|
37
42
|
# get a compiler with an attached compiled catalog
|
38
43
|
def build_compiler(node_name, fact_values)
|
39
|
-
|
44
|
+
node_options = {
|
45
|
+
:name => node_name,
|
46
|
+
:options => { :parameters => fact_values },
|
47
|
+
}
|
48
|
+
node = PuppetInternals.node(node_options)
|
49
|
+
compiler = PuppetInternals.compiler(:node => node)
|
40
50
|
compiler.compile
|
41
51
|
compiler
|
42
52
|
end
|
@@ -8,6 +8,9 @@ module RSpec::Puppet
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def catalogue
|
11
|
+
vardir = Dir.mktmpdir
|
12
|
+
Puppet[:vardir] = vardir
|
13
|
+
Puppet[:hiera_config] = File.join(vardir, "hiera.yaml") if Puppet[:hiera_config] == File.expand_path("/dev/null")
|
11
14
|
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
12
15
|
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
|
13
16
|
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
|
@@ -24,7 +27,9 @@ module RSpec::Puppet
|
|
24
27
|
}
|
25
28
|
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
|
26
29
|
|
27
|
-
build_catalog(nodename, facts_val, code)
|
30
|
+
catalogue = build_catalog(nodename, facts_val, code)
|
31
|
+
FileUtils.rm_rf(vardir) if File.directory?(vardir)
|
32
|
+
catalogue
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
data/rspec-puppet.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rspec-puppet'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.5'
|
4
4
|
s.homepage = 'https://github.com/rodjek/rspec-puppet/'
|
5
5
|
s.summary = 'RSpec tests for your Puppet manifests'
|
6
6
|
s.description = 'RSpec tests for your Puppet manifests'
|
@@ -6,6 +6,12 @@ describe 'split' do
|
|
6
6
|
it { should_not run.with_params('foo').and_raise_error(Puppet::DevError) }
|
7
7
|
|
8
8
|
it 'something' do
|
9
|
-
|
9
|
+
if Integer(Puppet.version.split('.').first) >= 3
|
10
|
+
expected_error = ArgumentError
|
11
|
+
else
|
12
|
+
expected_error = Puppet::ParseError
|
13
|
+
end
|
14
|
+
|
15
|
+
expect { subject.call('foo') }.to raise_error(expected_error)
|
10
16
|
end
|
11
17
|
end
|
metadata
CHANGED
@@ -1,46 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 4
|
10
|
-
version: 0.1.4
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Tim Sharpe
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rspec
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
35
30
|
description: RSpec tests for your Puppet manifests
|
36
31
|
email: tim@sharpe.id.au
|
37
|
-
executables:
|
32
|
+
executables:
|
38
33
|
- rspec-puppet-init
|
39
34
|
extensions: []
|
40
|
-
|
41
35
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
36
|
+
files:
|
44
37
|
- bin/rspec-puppet-init
|
45
38
|
- lib/rspec-puppet/example/class_example_group.rb
|
46
39
|
- lib/rspec-puppet/example/define_example_group.rb
|
@@ -71,39 +64,28 @@ files:
|
|
71
64
|
- spec/fixtures/modules/sysctl/manifests/init.pp
|
72
65
|
- spec/functions/split_spec.rb
|
73
66
|
- spec/spec_helper.rb
|
74
|
-
has_rdoc: true
|
75
67
|
homepage: https://github.com/rodjek/rspec-puppet/
|
76
68
|
licenses: []
|
77
|
-
|
78
69
|
post_install_message:
|
79
70
|
rdoc_options: []
|
80
|
-
|
81
|
-
require_paths:
|
71
|
+
require_paths:
|
82
72
|
- lib
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
74
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
90
|
-
- 0
|
91
|
-
version: "0"
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
80
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
101
85
|
requirements: []
|
102
|
-
|
103
86
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.8.23
|
105
88
|
signing_key:
|
106
89
|
specification_version: 3
|
107
90
|
summary: RSpec tests for your Puppet manifests
|
108
91
|
test_files: []
|
109
|
-
|