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, %r{Wrong number of arguments, expects one}) }
6 it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) }
7 it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) }
8 it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Could not find module}) }
18 describe 'when locating a module' do
19 let(:modulepath) { '/tmp/does_not_exist' }
20 let(:path_of_module_foo) { StubModule.new('/tmp/does_not_exist/foo') }
23 Puppet[:modulepath] = modulepath
26 context 'when in the default environment' do
28 allow(Puppet::Module).to receive(:find).with('foo', 'rp_env').and_return(path_of_module_foo)
30 it 'runs against foo' do
31 is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
34 it 'when the modulepath is a list' do
35 Puppet[:modulepath] = modulepath + 'tmp/something_else'
37 is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
41 context 'when in a non-default default environment' do
42 let(:environment) { 'test' }
45 allow(Puppet::Module).to receive(:find).with('foo', 'test').and_return(path_of_module_foo)
47 it 'runs against foo' do
48 is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
51 it 'when the modulepath is a list' do
52 Puppet[:modulepath] = modulepath + 'tmp/something_else'
53 is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)