Skip to content

Commit 6cba6b9

Browse files
authored
Merge pull request puppetlabs#39 from h4l/patch-1
2 parents 1508b51 + 84f1df7 commit 6cba6b9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,17 @@ Some complex functions require access to the current parser's scope, e.g. for
987987
stubbing 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

9941003
Note that this does not work when testing manifests which use custom functions. Instead,

0 commit comments

Comments
 (0)