Module: RSpec::Puppet::FunctionExampleGroup
- Includes:
- FunctionMatchers, ManifestMatchers, Support
- Defined in:
- lib/rspec-puppet/example/function_example_group.rb
Defined Under Namespace
Classes: V3FunctionWrapper, V4FunctionWrapper
Instance Method Summary
collapse
Instance Method Details
#catalogue ⇒ Object
94
95
96
|
# File 'lib/rspec-puppet/example/function_example_group.rb', line 94
def catalogue
@catalogue ||= compiler.catalog
end
|
#find_function ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/rspec-puppet/example/function_example_group.rb', line 64
def find_function
function_name = self.class.top_level_description.downcase
with_vardir do
env = adapter.current_environment
if Puppet.version.to_f >= 4.0
context_overrides = compiler.context_overrides
func = nil
Puppet.override(context_overrides, "rspec-test scope") do
loader = Puppet::Pops::Loaders.new(env)
func = V4FunctionWrapper.new(function_name, loader.private_environment_loader.load(:function, function_name), context_overrides)
@scope = context_overrides[:global_scope]
end
return func if func.func
end
if Puppet::Parser::Functions.function(function_name)
V3FunctionWrapper.new(function_name, scope.method("function_#{function_name}".intern))
else
nil
end
end
end
|
#rspec_puppet_cleanup ⇒ Object
98
99
100
101
102
103
|
# File 'lib/rspec-puppet/example/function_example_group.rb', line 98
def rspec_puppet_cleanup
@subject = nil
@catalogue = nil
@compiler = nil
@scope = nil
end
|
#scope ⇒ Object
90
91
92
|
# File 'lib/rspec-puppet/example/function_example_group.rb', line 90
def scope
@scope ||= build_scope(compiler, nodename(:function))
end
|
#subject ⇒ Object
(at least) rspec 3.5 doesn’t seem to memoize ‘subject` when called from a before(:each) hook, so we need to memoize it ourselves.
60
61
62
|
# File 'lib/rspec-puppet/example/function_example_group.rb', line 60
def subject
@subject ||= find_function
end
|