4 it 'should issue a warning' do
5 scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
13 context "when called from inside module" do
14 it "should not fail" do
15 scope.expects(:lookupvar).with('module_name').returns('foo')
16 scope.expects(:lookupvar).with('caller_module_name').returns('foo')
23 context "with an explicit failure message" do
24 it "prints the failure message on error" do
25 scope.expects(:lookupvar).with('module_name').returns('foo')
26 scope.expects(:lookupvar).with('caller_module_name').returns('bar')
28 subject.call ['failure message!']
29 }.to raise_error Puppet::ParseError, /failure message!/
33 context "when called from private class" do
34 it "should fail with a class error message" do
35 scope.expects(:lookupvar).with('module_name').returns('foo')
36 scope.expects(:lookupvar).with('caller_module_name').returns('bar')
37 scope.source.expects(:name).returns('foo::baz')
38 scope.source.expects(:type).returns('hostclass')
41 }.to raise_error Puppet::ParseError, /Class foo::baz is private/
45 context "when called from private definition" do
46 it "should fail with a class error message" do
47 scope.expects(:lookupvar).with('module_name').returns('foo')
48 scope.expects(:lookupvar).with('caller_module_name').returns('bar')
49 scope.source.expects(:name).returns('foo::baz')
50 scope.source.expects(:type).returns('definition')
53 }.to raise_error Puppet::ParseError, /Definition foo::baz is private/