3 describe 'assert_private' do
4 context 'when called from inside module' do
5 it "should not fail" do
6 scope.expects(:lookupvar).with('module_name').returns('foo')
7 scope.expects(:lookupvar).with('caller_module_name').returns('foo')
9 is_expected.to run.with_params()
13 context "when called from private class" do
15 scope.expects(:lookupvar).with('module_name').returns('foo')
16 scope.expects(:lookupvar).with('caller_module_name').returns('bar')
19 it "should fail with a class error message" do
20 scope.source.expects(:name).returns('foo::baz')
21 scope.source.expects(:type).returns('hostclass')
23 is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Class foo::baz is private/)
26 context "with an explicit failure message" do
27 it { is_expected.to run.with_params('failure message!').and_raise_error(Puppet::ParseError, /failure message!/) }
31 context "when called from private definition" do
32 it "should fail with a class error message" do
33 scope.expects(:lookupvar).with('module_name').returns('foo')
34 scope.expects(:lookupvar).with('caller_module_name').returns('bar')
35 scope.source.expects(:name).returns('foo::baz')
36 scope.source.expects(:type).returns('definition')
38 is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Definition foo::baz is private/)