File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -987,8 +987,17 @@ Some complex functions require access to the current parser's scope, e.g. for
987987stubbing other parts of the system.
988988
989989``` ruby
990- before(:each ) { scope.expects(:lookupvar ).with(' some_variable' ).returns(' some_value' ) }
991- it { is_expected.to run.with_params(' ...' ).and_return(' ...' ) }
990+ context ' when called with top-scope vars foo and bar set' do
991+ before do
992+ # :lookupvar is the method on scope that puppet calls internally to
993+ # resolve the value of a variable.
994+ allow(scope).to receive(:lookupvar ).and_call_original
995+ allow(scope).to receive(:lookupvar ).with(' ::foo' ).and_return(' Hello' )
996+ allow(scope).to receive(:lookupvar ).with(' ::bar' ).and_return(' World' )
997+ end
998+
999+ it { is_expected.to run.with_params().and_return(' Hello World' ) }
1000+ end
9921001```
9931002
9941003Note that this does not work when testing manifests which use custom functions. Instead,
You can’t perform that action at this time.
0 commit comments