Permalink
Browse files

Preliminary Puppet 3.0 support

  • Loading branch information...
Tim Sharpe
Tim Sharpe committed Oct 2, 2012
1 parent 4afd64e commit 60ec4aef7b7b15f847425bab8fa5d3cf0511ff5e
View
@@ -1,9 +1,15 @@
require 'puppet'
require 'rspec'
+require 'fileutils'
+require 'tmpdir'
require 'rspec-puppet/matchers'
require 'rspec-puppet/example'
require 'rspec-puppet/setup'
+if Integer(Puppet.version.split('.').first) >= 3
+ Puppet.initialize_settings
+end
+
RSpec.configure do |c|
c.add_setting :module_path, :default => '/etc/puppet/modules'
c.add_setting :manifest_dir, :default => nil
@@ -8,6 +8,9 @@ def subject
end
def catalogue
+ vardir = Dir.mktmpdir
+ Puppet[:vardir] = vardir
+ Puppet[:hiera_config] = File.join(vardir, "hiera.yaml") if Puppet[:hiera_config] == "/dev/null"
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
@@ -49,7 +52,9 @@ def catalogue
}
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
- build_catalog(nodename, facts_val, code)
+ catalogue = build_catalog(nodename, facts_val, code)
+ FileUtils.rm_rf(vardir) if File.directory?(vardir)
+ catalogue
end
end
end
@@ -10,6 +10,8 @@ def subject
def catalogue
define_name = self.class.top_level_description.downcase
+ vardir = Dir.mktmpdir
+ Puppet[:vardir] = vardir
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
@@ -51,7 +53,9 @@ def catalogue
}
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
- build_catalog(nodename, facts_val, code)
+ catalogue = build_catalog(nodename, facts_val, code)
+ FileUtils.rm_rf(vardir) if File.directory?(vardir)
+ catalogue
end
end
end
@@ -8,6 +8,8 @@ def subject
end
def catalogue
+ vardir = Dir.mktmpdir
+ Puppet[:vardir] = vardir
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
@@ -24,7 +26,9 @@ def catalogue
}
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
- build_catalog(nodename, facts_val, code)
+ catalogue = build_catalog(nodename, facts_val, code)
+ FileUtils.rm_rf(vardir) if File.directory?(vardir)
+ catalogue
end
end
end
@@ -6,6 +6,6 @@
it { should_not run.with_params('foo').and_raise_error(Puppet::DevError) }
it 'something' do
- expect { subject.call('foo') }.to raise_error(Puppet::ParseError)
+ expect { subject.call('foo') }.to raise_error(ArgumentError)
end
end

0 comments on commit 60ec4ae

Please sign in to comment.