rspec-puppet 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rspec-puppet.rb +0 -4
- data/lib/rspec-puppet/example/class_example_group.rb +5 -1
- data/lib/rspec-puppet/example/define_example_group.rb +5 -1
- data/lib/rspec-puppet/example/function_example_group.rb +14 -8
- data/lib/rspec-puppet/matchers/run.rb +1 -1
- data/lib/rspec-puppet/support.rb +6 -0
- data/rspec-puppet.gemspec +1 -1
- data/spec/defines/sysctl_before_spec.rb +3 -1
- metadata +2 -2
data/lib/rspec-puppet.rb
CHANGED
@@ -6,10 +6,6 @@ require 'rspec-puppet/matchers'
|
|
6
6
|
require 'rspec-puppet/example'
|
7
7
|
require 'rspec-puppet/setup'
|
8
8
|
|
9
|
-
if Integer(Puppet.version.split('.').first) >= 3
|
10
|
-
Puppet.initialize_settings
|
11
|
-
end
|
12
|
-
|
13
9
|
RSpec.configure do |c|
|
14
10
|
c.add_setting :module_path, :default => '/etc/puppet/modules'
|
15
11
|
c.add_setting :manifest_dir, :default => nil
|
@@ -11,17 +11,23 @@ module RSpec::Puppet
|
|
11
11
|
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
12
12
|
Puppet[:libdir] = Dir["#{Puppet[:modulepath]}/*/lib"].entries.join(File::PATH_SEPARATOR)
|
13
13
|
|
14
|
+
nodename = self.respond_to?(:node) ? node : Puppet[:certname]
|
15
|
+
facts_val = {
|
16
|
+
'hostname' => nodename.split('.').first,
|
17
|
+
'fqdn' => nodename,
|
18
|
+
'domain' => nodename.split('.').last,
|
19
|
+
}
|
20
|
+
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
|
21
|
+
facts_val.each { |k, v| Facter.add(k) { setcode { v } } }
|
22
|
+
|
14
23
|
# if we specify a pre_condition, we should ensure that we compile that code
|
15
24
|
# into a catalog that is accessible from the scope where the function is called
|
16
25
|
if self.respond_to? :pre_condition
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
'domain' => nodename.split('.').last,
|
23
|
-
}
|
24
|
-
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
|
26
|
+
if pre_condition.kind_of?(Array)
|
27
|
+
Puppet[:code] = pre_condition.join("\n")
|
28
|
+
else
|
29
|
+
Puppet[:code] = pre_condition
|
30
|
+
end
|
25
31
|
# we need to get a compiler, b/c we can attach that to a scope
|
26
32
|
@compiler = build_compiler(nodename, facts_val)
|
27
33
|
else
|
data/lib/rspec-puppet/support.rb
CHANGED
@@ -5,8 +5,14 @@ module RSpec::Puppet
|
|
5
5
|
|
6
6
|
protected
|
7
7
|
def build_catalog_without_cache(nodename, facts_val, code)
|
8
|
+
if Integer(Puppet.version.split('.').first) >= 3
|
9
|
+
Puppet.initialize_settings
|
10
|
+
end
|
11
|
+
|
8
12
|
Puppet[:code] = code
|
9
13
|
|
14
|
+
facts_val.each { |k, v| Facter.add(k) { setcode { v } } }
|
15
|
+
|
10
16
|
node_obj = Puppet::Node.new(nodename)
|
11
17
|
|
12
18
|
node_obj.merge(facts_val)
|
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.6'
|
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'
|
@@ -13,7 +13,9 @@ end
|
|
13
13
|
|
14
14
|
describe 'sysctl::before' do
|
15
15
|
let(:title) { 'test define' }
|
16
|
-
let(:pre_condition) {
|
16
|
+
let(:pre_condition) {
|
17
|
+
[ '# we need sysctl common',
|
18
|
+
'class {"sysctl::common":}' ] }
|
17
19
|
let(:params) { { :value => "title" } }
|
18
20
|
|
19
21
|
it { should create_resource("sysctl::before", 'test define')\
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|