Class: RSpecPuppetUtils::MockFunction
- Inherits:
-
Object
- Object
- RSpecPuppetUtils::MockFunction
- Defined in:
- lib/mock_function.rb
Instance Method Summary collapse
- #expect(*args) ⇒ Object
-
#initialize(name, options = {}) {|_self| ... } ⇒ MockFunction
constructor
A new instance of MockFunction.
- #stub ⇒ Object
Constructor Details
#initialize(name, options = {}) {|_self| ... } ⇒ MockFunction
Returns a new instance of MockFunction.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mock_function.rb', line 16 def initialize(name, = {}) this = self Puppet::Parser::Functions.newfunction(name.to_sym, ) { |args| this.call args} yield self if block_given? if [: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
#expect(*args) ⇒ Object
35 36 37 38 |
# File 'lib/mock_function.rb', line 35 def expect(*args) RSpec::Puppet::Support.clear_cache unless args.include? :keep_cache self.expects(:call) end |
#stub ⇒ Object
31 32 33 |
# File 'lib/mock_function.rb', line 31 def stub self.stubs(:call) end |