spec/unit/module_loader/puppetfile_spec.rb in r10k-3.14.0 vs spec/unit/module_loader/puppetfile_spec.rb in r10k-3.14.1

- old
+ new

@@ -78,11 +78,12 @@ end describe 'adding modules' do let(:basedir) { '/test/basedir' } - subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir) } + subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir, + overrides: {modules: {exclude_spec: true}}) } it 'should transform Forge modules with a string arg to have a version key' do expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules } @@ -92,12 +93,24 @@ it 'should not accept Forge modules with a version comparison' do expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original expect { subject.add_module('puppet/test_module', '< 1.2.0') - }.to raise_error(RuntimeError, /module puppet\/test_module.*doesn't have an implementation/i) + }.to raise_error(ArgumentError, /module version .* is not a valid forge module version/i) expect(subject.modules.collect(&:name)).not_to include('test_module') + end + + it 'should not modify the overrides when adding modules' do + module_opts = { git: 'git@example.com:puppet/test_module.git' } + subject.add_module('puppet/test_module', module_opts) + expect(subject.instance_variable_get("@overrides")[:modules]).to eq({exclude_spec: true}) + end + + it 'should read the `exclude_spec` setting in the module definition and override the overrides' do + module_opts = { git: 'git@example.com:puppet/test_module.git', exclude_spec: false } + subject.add_module('puppet/test_module', module_opts) + expect(subject.modules[0].instance_variable_get("@exclude_spec")).to be false end it 'should set :spec_deletable to true for modules in the basedir' do module_opts = { git: 'git@example.com:puppet/test_module.git' } subject.add_module('puppet/test_module', module_opts)