Default module_path set in RSpec.configure
Can still be overridden with let(:module_path) as before
This commit is contained in:
parent
4c9d43aec8
commit
a9dbacd03e
|
@ -1,3 +1,7 @@
|
|||
require 'puppet'
|
||||
require 'rspec-puppet/matchers'
|
||||
require 'rspec-puppet/example'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.add_setting :module_path, :default => '/etc/puppet/modules'
|
||||
end
|
||||
|
|
|
@ -7,15 +7,15 @@ module RSpec::Puppet
|
|||
end
|
||||
|
||||
def catalogue
|
||||
Puppet[:modulepath] = module_path
|
||||
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
||||
|
||||
klass_name = self.class.top_level_description.downcase
|
||||
|
||||
# If we're testing a standalone module (i.e. one that's outside of a
|
||||
# puppet tree), the autoloader won't work, so we need to fudge it a bit.
|
||||
if File.exists?(File.join(module_path, 'manifests', 'init.pp'))
|
||||
path_to_manifest = File.join([module_path, 'manifests', klass_name.split('::')[1..-1]].flatten)
|
||||
import_str = "import '#{module_path}/manifests/init.pp'\nimport '#{path_to_manifest}.pp'\n"
|
||||
if File.exists?(File.join(Puppet[:modulepath], 'manifests', 'init.pp'))
|
||||
path_to_manifest = File.join([Puppet[:modulepath], 'manifests', klass_name.split('::')[1..-1]].flatten)
|
||||
import_str = "import '#{Puppet[:modulepath]}/manifests/init.pp'\nimport '#{path_to_manifest}.pp'\n"
|
||||
else
|
||||
import_str = ""
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ module RSpec::Puppet
|
|||
def catalogue
|
||||
define_name = self.class.top_level_description.downcase
|
||||
|
||||
Puppet[:modulepath] = module_path
|
||||
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
|
||||
|
||||
# If we're testing a standalone module (i.e. one that's outside of a
|
||||
# puppet tree), the autoloader won't work, so we need to fudge it a bit.
|
||||
if File.exists?(File.join(module_path, 'manifests', 'init.pp'))
|
||||
path_to_manifest = File.join([module_path, 'manifests', define_name.split('::')[1..-1]].flatten)
|
||||
import_str = "import '#{module_path}/manifests/init.pp'\nimport '#{path_to_manifest}.pp'\n"
|
||||
if File.exists?(File.join(Puppet[:modulepath], 'manifests', 'init.pp'))
|
||||
path_to_manifest = File.join([Puppet[:modulepath], 'manifests', define_name.split('::')[1..-1]].flatten)
|
||||
import_str = "import '#{Puppet[:modulepath]}/manifests/init.pp'\nimport '#{path_to_manifest}.pp'\n"
|
||||
else
|
||||
import_str = ""
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue