Class: RSpec::Puppet::FunctionExampleGroup::V3FunctionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-puppet/example/function_example_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, func) ⇒ V3FunctionWrapper

Returns a new instance of V3FunctionWrapper.



33
34
35
36
# File 'lib/rspec-puppet/example/function_example_group.rb', line 33

def initialize(name, func)
  @func_name = name
  @func = func
end

Instance Attribute Details

#func_nameObject

Returns the value of attribute func_name.



31
32
33
# File 'lib/rspec-puppet/example/function_example_group.rb', line 31

def func_name
  @func_name
end

Instance Method Details

#call(*args) ⇒ Object

This method was formerly used by the ‘run` matcher to trigger the function execution, and provides puppet versions dependant interface.



48
49
50
51
52
53
54
55
# File 'lib/rspec-puppet/example/function_example_group.rb', line 48

def call(*args)
  RSpec.deprecate("subject.call", :replacement => "is_expected.to run.with().and_raise_error(), or execute()")
  if args.nil?
    @func.call
  else
    @func.call(*args)
  end
end

#execute(*args) ⇒ Object

This method is used by the ‘run` matcher to trigger the function execution, and provides a uniform interface across all puppet versions.



39
40
41
42
43
44
45
# File 'lib/rspec-puppet/example/function_example_group.rb', line 39

def execute(*args)
  if args.nil?
    @func.call
  else
    @func.call(args)
  end
end