Skip to content

Commit 6d96367

Browse files
committed
(#11156) Fix module path fixtures so rspec works in most rubies
Previously this module was using an experimental pattern using mktmpdir for creating its module path for rspec-puppet to use, which has since been deprecated in favour of a static directory. This was largely because ntp was one of the earlier modules we tried to make work in Jenkins. This change aligns the module to use the same pattern used in the rspec- puppet setup stage: https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/setup.rb This should stop the problems with Ruby 1.8.5 complaining about a lack of mktmpdir, and also make it more consistent with other modules in the wild.
1 parent 0b39d32 commit 6d96367

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

spec/fixtures/manifests/site.pp

Whitespace-only changes.

spec/fixtures/modules/ntp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../

spec/spec_helper.rb

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
require 'puppet'
22
require 'rspec-puppet'
3-
require 'tmpdir'
3+
require 'puppet_spec_helper'
44

5-
RSpec.configure do |c|
6-
c.before :each do
7-
# Create a temporary puppet confdir area and temporary site.pp so
8-
# when rspec-puppet runs we don't get a puppet error.
9-
@puppetdir = Dir.mktmpdir("ntp")
10-
manifestdir = File.join(@puppetdir, "manifests")
11-
Dir.mkdir(manifestdir)
12-
FileUtils.touch(File.join(manifestdir, "site.pp"))
13-
Puppet[:confdir] = @puppetdir
14-
Puppet.settings.send(:initialize_everything_for_tests) unless Puppet.version =~ /^2\.6/
15-
end
16-
17-
c.after :each do
18-
Puppet.settings.send(:clear_everything_for_tests) unless Puppet.version =~ /^2\.6/
19-
FileUtils.remove_entry_secure(@puppetdir)
20-
end
5+
fixture_dir = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures")
216

22-
c.module_path = File.join(File.dirname(__FILE__), '../../')
7+
RSpec.configure do |c|
8+
c.module_path = File.join(fixture_dir, 'modules')
9+
c.manifest_dir = File.join(fixture_dir, 'manifests')
2310
end

0 commit comments

Comments
 (0)