Class: RSpecPuppetUtils::MockFunction
- Inherits:
-
Object
- Object
- RSpecPuppetUtils::MockFunction
- Defined in:
- lib/rspec_puppet_utils/mock_function.rb
Instance Method Summary collapse
- #call(args) ⇒ Object
- #execute(*args) ⇒ Object
-
#expect(*args) ⇒ Object
Use expected instead, see readme.
- #expected(*args) ⇒ Object
-
#initialize(name, options = {}) {|_self| ... } ⇒ MockFunction
constructor
A new instance of MockFunction.
-
#stub ⇒ Object
Use stubbed instead, see readme.
- #stubbed ⇒ Object
Constructor Details
#initialize(name, options = {}) {|_self| ... } ⇒ MockFunction
Returns a new instance of MockFunction.
22 23 24 25 26 27 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 22 def initialize(name, = {}) this = self Puppet::Parser::Functions.newfunction(name.to_sym, ) { |args| this.call args } yield self if block_given? end |
Instance Method Details
#call(args) ⇒ Object
29 30 31 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 29 def call(args) execute *args end |
#execute(*args) ⇒ Object
33 34 35 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 33 def execute(*args) args end |
#expect(*args) ⇒ Object
Use expected instead, see readme
52 53 54 55 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 52 def expect(*args) RSpec::Puppet::Support.clear_cache unless args.include? :keep_cache self.expects(:call) end |
#expected(*args) ⇒ Object
41 42 43 44 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 41 def expected(*args) RSpec::Puppet::Support.clear_cache unless args.include? :keep_cache self.expects(:execute) end |
#stub ⇒ Object
Use stubbed instead, see readme
47 48 49 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 47 def stub self.stubs(:call) end |
#stubbed ⇒ Object
37 38 39 |
# File 'lib/rspec_puppet_utils/mock_function.rb', line 37 def stubbed self.stubs(:execute) end |