X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fsetting_spec.rb;h=a2fef2e24a2c48fb82c32b0c54f1b59c9960426b;hb=2fef8544ec0ee5ef6b7182ab56a7487194e28657;hp=0b6ca99b60eadb5f706c4da31f6d51b257f4d2f8;hpb=c7013c082891edae1543c6244f1f0719dae98d13;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 0b6ca99..a2fef2e 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -1,16 +1,23 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } let :facts do { - os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistrelease: '7.0', - lsbdistcodename: 'wheezy', - operatingsystem: 'Debian', - osfamily: 'Debian', - lsbdistid: 'Debian', - puppetversion: Puppet.version, + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:title) { 'conf-teddybear' } @@ -20,7 +27,7 @@ describe 'apt::setting' do describe 'when using the defaults' do context 'without source or content' do it do - expect { subject.call }.to raise_error(Puppet::Error, %r{needs either of }) + is_expected.to raise_error(Puppet::Error, %r{needs either of }) end end @@ -51,7 +58,6 @@ describe 'apt::setting' do is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', owner: 'root', group: 'root', - mode: '0644', source: params[:source].to_s) } end @@ -63,7 +69,6 @@ describe 'apt::setting' do is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', owner: 'root', group: 'root', - mode: '0644', content: params[:content].to_s) } end @@ -77,11 +82,18 @@ describe 'apt::setting' do end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'wheezy', - puppetversion: Puppet.version, + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:title) { 'conf-teddybear' } @@ -97,7 +109,7 @@ describe 'apt::setting' do let(:params) { default_params.merge(source: 'la') } it do - expect { subject.call }.to raise_error(Puppet::Error, %r{cannot have both }) + is_expected.to raise_error(Puppet::Error, %r{cannot have both }) end end @@ -106,7 +118,7 @@ describe 'apt::setting' do let(:params) { default_params } it do - expect { subject.call }.to raise_error(Puppet::Error, %r{must start with either}) + is_expected.to raise_error(Puppet::Error, %r{must start with either}) end end @@ -114,18 +126,14 @@ describe 'apt::setting' do let(:params) { default_params.merge(ensure: 'banana') } it do - expect { subject.call }.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}) + is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}) end end context 'with priority=1.2' do let(:params) { default_params.merge(priority: 1.2) } - if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') >= 0 || ENV['FUTURE_PARSER'] == 'yes' - it { is_expected.to compile.and_raise_error(%r{expects a value of type}) } - else - it { is_expected.to compile.and_raise_error(%r{priority must be an integer or a zero-padded integer}) } - end + it { is_expected.to compile.and_raise_error(%r{expects a value of type}) } end end