class RSpec::Puppet::FunctionExampleGroup::V4FunctionWrapper
Attributes
func[R]
func_name[R]
Public Class Methods
new(name, func, overrides)
click to toggle source
# File lib/rspec-puppet/example/function_example_group.rb, line 12 def initialize(name, func, overrides) @func_name = name @func = func @overrides = overrides end
Public Instance Methods
call(_scope, *args)
click to toggle source
compatibility alias for existing tests
# File lib/rspec-puppet/example/function_example_group.rb, line 26 def call(_scope, *args) RSpec.deprecate('subject.call', replacement: 'is_expected.to run.with().and_raise_error(), or execute()') execute(*args) end
execute(*args, &block)
click to toggle source
This method is used by the ‘run` matcher to trigger the function execution, and provides a uniform interface across all puppet versions.
# File lib/rspec-puppet/example/function_example_group.rb, line 19 def execute(*args, &block) Puppet.override(@overrides, 'rspec-test scope') do @func.call(@overrides[:global_scope], *freeze_arg(args), &block) end end
Private Instance Methods
freeze_arg(arg)
click to toggle source
Facts, keywords, single-quoted strings etc. are usually frozen in Puppet
manifests, so freeze arguments to ensure functions are tested under worst-case conditions.
# File lib/rspec-puppet/example/function_example_group.rb, line 35 def freeze_arg(arg) case arg when Array arg.each { |a| freeze_arg(a) } arg.freeze when Hash arg.each do |k, v| freeze_arg(k) freeze_arg(v) end arg.freeze when String arg.freeze end arg end