Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Apr 27, 2019
1 parent e10d6e2 commit 6e15572
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions lib/rspec-puppet/example/function_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,9 @@ def find_function(function_name = self.class.top_level_description)

# allow loading functions from the environment
Puppet.override(context_overrides, "rspec-test scope") do
env_libdirs = env.modulepath.map { |r|
File.join(File.dirname(r), 'lib')
}
dir = env_libdirs.find { |r| File.directory?(r) }
loader_dir = loader_needs_lib? ? dir : File.dirname(dir)
module_name = if Puppet::Pops::Loader.const_defined?(:ENVIRONMENT)
Puppet::Pops::Loader::ENVIRONMENT
else
nil
end
loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(loaders.private_environment_loader, loaders, module_name, loader_dir, 'environment functions', [:func_4x])
env_dirs = env.modulepath.map { |r| File.dirname(r) }
dir = env_dirs.find { |r| File.directory?(File.join(r, 'lib')) }
loader = Puppet::Pops::Loader::ModuleLoaders.environment_loader_from(loaders.private_environment_loader, loaders, dir)
func = V4FunctionWrapper.new(function_name, loader.load(:function, function_name), context_overrides)
@scope = context_overrides[:global_scope]
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/environment_upcase_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'

describe 'environment::upcase' do
describe 'environment::upcase', :if => Puppet.version.to_i >= 4 do
it { should run.with_params('aaa').and_return('AAA') }
end

0 comments on commit 6e15572

Please sign in to comment.