Class: RSpec::Puppet::FunctionExampleGroup::V4FunctionWrapper
- Inherits:
-
Object
- Object
- RSpec::Puppet::FunctionExampleGroup::V4FunctionWrapper
- Defined in:
- lib/rspec-puppet/example/function_example_group.rb
Instance Attribute Summary collapse
-
#func ⇒ Object
readonly
Returns the value of attribute func.
-
#func_name ⇒ Object
readonly
Returns the value of attribute func_name.
Instance Method Summary collapse
-
#call(scope, *args) ⇒ Object
compatibility alias for existing tests.
-
#execute(*args, &block) ⇒ Object
This method is used by the ‘run` matcher to trigger the function execution, and provides a uniform interface across all puppet versions.
-
#initialize(name, func, overrides) ⇒ V4FunctionWrapper
constructor
A new instance of V4FunctionWrapper.
Constructor Details
#initialize(name, func, overrides) ⇒ V4FunctionWrapper
Returns a new instance of V4FunctionWrapper.
10 11 12 13 14 |
# File 'lib/rspec-puppet/example/function_example_group.rb', line 10 def initialize(name, func, overrides) @func_name = name @func = func @overrides = overrides end |
Instance Attribute Details
#func ⇒ Object (readonly)
Returns the value of attribute func.
8 9 10 |
# File 'lib/rspec-puppet/example/function_example_group.rb', line 8 def func @func end |
#func_name ⇒ Object (readonly)
Returns the value of attribute func_name.
8 9 10 |
# File 'lib/rspec-puppet/example/function_example_group.rb', line 8 def func_name @func_name end |
Instance Method Details
#call(scope, *args) ⇒ Object
compatibility alias for existing tests
24 25 26 27 |
# File 'lib/rspec-puppet/example/function_example_group.rb', line 24 def call(scope, *args) RSpec.deprecate("subject.call", :replacement => "is_expected.to run.with().and_raise_error(), or execute()") execute(*args) end |
#execute(*args, &block) ⇒ Object
This method is used by the ‘run` matcher to trigger the function execution, and provides a uniform interface across all puppet versions.
17 18 19 20 21 |
# File 'lib/rspec-puppet/example/function_example_group.rb', line 17 def execute(*args, &block) Puppet.override(@overrides, "rspec-test scope") do @func.call(@overrides[:global_scope], *freeze_arg(args), &block) end end |