3 describe 'get_module_path' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
6 it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
7 it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
8 it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
17 describe 'when locating a module' do
18 let(:modulepath) { "/tmp/does_not_exist" }
19 let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") }
21 before(:each) { Puppet[:modulepath] = modulepath }
23 context 'in the default environment' do
24 before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').returns(path_of_module_foo) }
26 it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
28 context 'when the modulepath is a list' do
29 before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
31 it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
35 context 'in a non-default default environment' do
36 let(:environment) { 'test' }
37 before(:each) { Puppet::Module.expects(:find).with('foo', 'test').returns(path_of_module_foo) }
39 it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
41 context 'when the modulepath is a list' do
42 before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
44 it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }