Class: RSpecPuppetUtils::MockFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_function.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ MockFunction

Returns a new instance of MockFunction.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mock_function.rb', line 7

def initialize(name, options = {})
  parse_options! options
  if options[:type] == :rvalue
    this = self
    Puppet::Parser::Functions.newfunction(name.to_sym, options) { |args| this.call args}
    yield self if block_given?
  else
    # Even though the puppet function does not return a value,
    # this mock still needs to do something, what it returns doesn't really matter.
    Puppet::Parser::Functions.newfunction(name.to_sym, options) { |args| args }
  end
end