Class: RSpecPuppetUtils::MockFunction

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MockFunction.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(name, options = {})
  parse_options! options
  this = self
  Puppet::Parser::Functions.newfunction(name.to_sym, options) { |args| this.call args}
  yield self if block_given?

  if options[:type] == :statement
    # call is called on statement function incase expects(:call) is needed
    # The method is defined incase expects(:call) isn't used
    def this.call args
      args
    end
  end
end

Instance Method Details

#expectObject



27
28
29
# File 'lib/mock_function.rb', line 27

def expect
  self.expects(:call)
end

#stubObject



23
24
25
# File 'lib/mock_function.rb', line 23

def stub
  self.stubs(:call)
end