# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2023-04-21 09:13:34 UTC using RuboCop version 1.48.1.
+# on 2023-04-21 12:46:34 UTC using RuboCop version 1.48.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Exclude:
- 'spec/acceptance/apt_key_provider_spec.rb'
-# Offense count: 2
-# This cop supports safe autocorrection (--autocorrect).
-RSpec/ExcessiveDocstringSpacing:
+# Offense count: 3
+RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/defines/key_compat_spec.rb'
- - 'spec/defines/setting_spec.rb'
+ - 'spec/defines/source_compat_spec.rb'
+ - 'spec/defines/source_spec.rb'
+
+# Offense count: 3
+# Configuration parameters: AllowSubject.
+RSpec/MultipleMemoizedHelpers:
+ Max: 6
# Offense count: 204
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
-RSpec/ImplicitSubject:
+# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
+# SupportedStyles: always, named_only
+RSpec/NamedSubject:
Exclude:
- 'spec/classes/apt_backports_spec.rb'
- 'spec/classes/apt_spec.rb'
- 'spec/defines/source_spec.rb'
- 'spec/unit/facter/apt_update_last_success_spec.rb'
-# Offense count: 3
-RSpec/LeakyConstantDeclaration:
- Exclude:
- - 'spec/defines/key_compat_spec.rb'
- - 'spec/defines/source_compat_spec.rb'
- - 'spec/defines/source_spec.rb'
-
-# Offense count: 3
-# Configuration parameters: AllowSubject.
-RSpec/MultipleMemoizedHelpers:
- Max: 6
-
# Offense count: 2
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Exclude:
- 'tasks/init.rb'
-# Offense count: 10
-# This cop supports safe autocorrection (--autocorrect).
-Style/IfUnlessModifier:
- Exclude:
- - 'lib/facter/apt_updates.rb'
- - 'lib/puppet/provider/apt_key/apt_key.rb'
- - 'lib/puppet/type/apt_key.rb'
-
# Offense count: 1
Style/MixinUsage:
Exclude:
- 'spec/spec_helper.rb'
-# Offense count: 3
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
-Style/QuotedSymbols:
- Exclude:
- - 'spec/unit/puppet/provider/apt_key_spec.rb'
-
-# Offense count: 4
-# This cop supports safe autocorrection (--autocorrect).
-Style/RedundantRegexpEscape:
- Exclude:
- - 'lib/puppet/type/apt_key.rb'
-
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
%r{ gNewSense[^\s]+-security[, ]},
]
re = Regexp.union(security_matches)
- if line.match(re)
- apt_updates[1].push(package)
- end
+ apt_updates[1].push(package) if line.match(re)
end
end
end
confine osfamily: 'Debian'
setcode do
apt_package_updates = get_updates('upgrade')
- if !apt_package_updates.nil? && apt_package_updates.length == 2
- apt_package_updates != [[], []]
- end
+ apt_package_updates != [[], []] if !apt_package_updates.nil? && apt_package_updates.length == 2
end
end
confine osfamily: 'Debian'
setcode do
apt_dist_updates = get_updates('dist-upgrade')
- if !apt_dist_updates.nil? && apt_dist_updates.length == 2
- apt_dist_updates != [[], []]
- end
+ apt_dist_updates != [[], []] if !apt_dist_updates.nil? && apt_dist_updates.length == 2
end
end
expired = false
- if line_hash[:key_expiry]
- expired = Time.now >= line_hash[:key_expiry]
- end
+ expired = Time.now >= line_hash[:key_expiry] if line_hash[:key_expiry]
new(
name: line_hash[:key_fingerprint],
found_match = false
extracted_key.each_line do |line|
- if line.chomp == name
- found_match = true
- end
+ found_match = true if line.chomp == name
end
unless found_match
raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Layout/LineLength
# Breaking up the command like this is needed because it blows up
# if --recv-keys isn't the last argument.
command.push('adv', '--no-tty', '--keyserver', resource[:server])
- unless resource[:options].nil?
- command.push('--keyserver-options', resource[:options])
- end
+ command.push('--keyserver-options', resource[:options]) unless resource[:options].nil?
command.push('--recv-keys', resource[:id])
elsif resource[:content]
key_file = tempfile(resource[:content])
ensurable
validate do
- if self[:refresh] == true && self[:ensure] == :absent
- raise(_('ensure => absent and refresh => true are mutually exclusive'))
- end
- if self[:content] && self[:source]
- raise(_('The properties content and source are mutually exclusive.'))
- end
+ raise(_('ensure => absent and refresh => true are mutually exclusive')) if self[:refresh] == true && self[:ensure] == :absent
+ raise(_('The properties content and source are mutually exclusive.')) if self[:content] && self[:source]
- if self[:id].length < 40
- warning(_('The id should be a full fingerprint (40 characters), see README.'))
- end
+ warning(_('The id should be a full fingerprint (40 characters), see README.')) if self[:id].length < 40
end
newparam(:id, namevar: true) do
end
autorequire(:file) do
- if self[:source] && Pathname.new(self[:source]).absolute?
- self[:source]
- end
+ self[:source] if self[:source] && Pathname.new(self[:source]).absolute?
end
newparam(:server) do
desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
defaultto :'keyserver.ubuntu.com'
- newvalues(%r{\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$})
+ newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(/[a-zA-Z\d\-_.]+)*/?$})
end
newparam(:options) do
end
it {
- is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
- repos: 'main contrib non-free',
- release: 'stretch-backports',
- pin: { 'priority' => 200, 'release' => 'stretch-backports' })
+ expect(subject).to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
+ repos: 'main contrib non-free',
+ release: 'stretch-backports',
+ pin: { 'priority' => 200, 'release' => 'stretch-backports' })
}
end
end
it {
- is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
- key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
- repos: 'main universe multiverse restricted',
- release: 'bionac-backports',
- pin: { 'priority' => 200, 'release' => 'bionac-backports' })
+ expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
+ key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
+ repos: 'main universe multiverse restricted',
+ release: 'bionac-backports',
+ pin: { 'priority' => 200, 'release' => 'bionac-backports' })
}
end
end
it {
- is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
- key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
- repos: 'main',
- release: 'vivid',
- pin: { 'priority' => 90, 'release' => 'vivid' })
+ expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
+ key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
+ repos: 'main',
+ release: 'vivid',
+ pin: { 'priority' => 90, 'release' => 'vivid' })
}
end
end
it {
- is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
- pin: { 'priority' => '90' })
+ expect(subject).to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
+ pin: { 'priority' => '90' })
}
end
end
end
it {
- is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
- key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
- repos: 'main universe multiverse restricted',
- release: 'trusty-backports',
- pin: { 'priority' => 200, 'release' => 'trusty-backports' })
+ expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
+ key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
+ repos: 'main universe multiverse restricted',
+ release: 'trusty-backports',
+ pin: { 'priority' => 200, 'release' => 'trusty-backports' })
}
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+ expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+ expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+ expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
+ expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
end
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a})
end
end
end
context 'with defaults' do
it {
- is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list)
+ expect(subject).to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list)
}
it {
- is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d)
+ expect(subject).to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d)
}
it {
- is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences)
+ expect(subject).to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences)
}
it {
- is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
+ expect(subject).to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
}
it {
- is_expected.to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d)
+ expect(subject).to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d)
}
it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') }
it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
- is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
- owner: 'root').with_content(
- %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};},
- )
+ expect(subject).to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
+ owner: 'root').with_content(
+ %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};},
+ )
end
it {
- is_expected.to contain_exec('apt_update').with(refreshonly: 'true')
+ expect(subject).to contain_exec('apt_update').with(refreshonly: 'true')
}
it { is_expected.not_to contain_apt__setting('conf-proxy') }
let(:params) { { proxy: { 'host' => 'localhost' } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8080/";},
).without_content(
%r{Acquire::https::proxy },
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";},
)
}
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'port' => 8081 }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy::proxyscope "http://proxyhost:8081/";},
)
}
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'https' => true }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::https::proxy::proxyscope "https://proxyhost:8080/";},
)
}
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'direct' => true }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy::proxyscope "DIRECT";},
)
}
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'https' => true, 'direct' => true }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::https::proxy::proxyscope "DIRECT";},
)
}
let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }, { 'scope' => 'proxyscope2', 'host' => 'proxyhost2' }] } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";},
).with_content(
%r{Acquire::http::proxy::proxyscope2 "http://proxyhost2:8080/";},
let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8180/";},
).without_content(
%r{Acquire::https::proxy },
let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8080/";},
).with_content(
%r{Acquire::https::proxy "https://localhost:8080/";},
let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8080/";},
).with_content(
%r{Acquire::https::proxy "DIRECT";},
let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8080/";},
).with_content(
%r{Acquire::https::proxy "https://localhost:8080/";},
}
it {
- is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
+ expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
%r{Acquire::http::proxy "http://localhost:8080/";},
).without_content(
%r{Acquire::https::proxy "DIRECT";},
let(:params) { { proxy: { 'ensure' => 'absent' } } }
it {
- is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent',
- priority: '01')
+ expect(subject).to contain_apt__setting('conf-proxy').with(ensure: 'absent',
+ priority: '01')
}
end
end
end
it {
- is_expected.to contain_file('sources.list').with(content: nil)
+ expect(subject).to contain_file('sources.list').with(content: nil)
}
it {
- is_expected.to contain_file('sources.list.d').with(purge: false,
- recurse: false)
+ expect(subject).to contain_file('sources.list.d').with(purge: false,
+ recurse: false)
}
it {
- is_expected.to contain_file('preferences').with(ensure: 'file')
+ expect(subject).to contain_file('preferences').with(ensure: 'file')
}
it {
- is_expected.to contain_file('preferences.d').with(purge: false,
- recurse: false)
+ expect(subject).to contain_file('preferences.d').with(purge: false,
+ recurse: false)
}
it {
- is_expected.to contain_file('apt.conf.d').with(purge: false,
- recurse: false)
+ expect(subject).to contain_file('apt.conf.d').with(purge: false,
+ recurse: false)
}
it {
- is_expected.to contain_exec('apt_update').with(refreshonly: false,
- timeout: 1,
- tries: 3)
+ expect(subject).to contain_exec('apt_update').with(refreshonly: false,
+ timeout: 1,
+ tries: 3)
}
end
end
it {
- is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+ expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
}
it {
- is_expected.to contain_file('sources.list.d').with(purge: true,
- recurse: true)
+ expect(subject).to contain_file('sources.list.d').with(purge: true,
+ recurse: true)
}
it {
- is_expected.to contain_file('preferences').with(ensure: 'absent')
+ expect(subject).to contain_file('preferences').with(ensure: 'absent')
}
it {
- is_expected.to contain_file('preferences.d').with(purge: true,
- recurse: true)
+ expect(subject).to contain_file('preferences.d').with(purge: true,
+ recurse: true)
}
it {
- is_expected.to contain_file('apt.conf.d').with(purge: true,
- recurse: true)
+ expect(subject).to contain_file('apt.conf.d').with(purge: true,
+ recurse: true)
}
it {
- is_expected.to contain_exec('apt_update').with(refreshonly: false,
- timeout: 1,
- tries: 3)
+ expect(subject).to contain_exec('apt_update').with(refreshonly: false,
+ timeout: 1,
+ tries: 3)
}
end
end
it {
- is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+ expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
}
end
end
it {
- is_expected.to contain_file('sources.list').with(ensure: 'absent')
+ expect(subject).to contain_file('sources.list').with(ensure: 'absent')
}
end
"
it {
- is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
- owner: '_apt',
- group: 'root',
- mode: '0600',
- notify: 'Class[Apt::Update]',
- content: sensitive(auth_conf_content))
+ expect(subject).to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
+ owner: '_apt',
+ group: 'root',
+ mode: '0600',
+ notify: 'Class[Apt::Update]',
+ content: sensitive(auth_conf_content))
}
end
end
it {
- is_expected.not_to contain_file('/etc/apt/auth.conf')
+ expect(subject).not_to contain_file('/etc/apt/auth.conf')
}
end
end
end
it {
- is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
+ expect(subject).to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
}
it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
it {
- is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
+ expect(subject).to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
}
it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com bionic main$}) }
end
it {
- is_expected.to contain_apt__conf('foo').with(content: 'foo')
+ expect(subject).to contain_apt__conf('foo').with(content: 'foo')
}
it {
- is_expected.to contain_apt__conf('bar').with(content: 'bar')
+ expect(subject).to contain_apt__conf('bar').with(content: 'bar')
}
end
end
it {
- is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
+ expect(subject).to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
}
it {
- is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
+ expect(subject).to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
}
end
let(:params) { { purge: { 'sources.list' => 'banana' } } }
it do
- is_expected.to raise_error(Puppet::Error)
+ expect(subject).to raise_error(Puppet::Error)
end
end
let(:params) { { purge: { 'sources.list.d' => 'banana' } } }
it do
- is_expected.to raise_error(Puppet::Error)
+ expect(subject).to raise_error(Puppet::Error)
end
end
let(:params) { { purge: { 'preferences' => 'banana' } } }
it do
- is_expected.to raise_error(Puppet::Error)
+ expect(subject).to raise_error(Puppet::Error)
end
end
let(:params) { { purge: { 'preferences.d' => 'banana' } } }
it do
- is_expected.to raise_error(Puppet::Error)
+ expect(subject).to raise_error(Puppet::Error)
end
end
let(:params) { { purge: { 'apt.conf.d' => 'banana' } } }
it do
- is_expected.to raise_error(Puppet::Error)
+ expect(subject).to raise_error(Puppet::Error)
end
end
end
it 'triggers an apt-get update run' do
# set the apt_update exec's refreshonly attribute to false
- is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
end
end
end
it 'triggers an apt-get update run' do
# set the apt_update exec\'s refreshonly attribute to false
- is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
end
end
it 'skips an apt-get update run' do
# set the apt_update exec's refreshonly attribute to false
- is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
end
end
end
it 'does not trigger an apt-get update run' do
# don't change the apt_update exec's refreshonly attribute. (it should be true)
- is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
end
end
end
it 'does not trigger an apt-get update run' do
# don't change the apt_update exec's refreshonly attribute. (it should be true)
- is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
end
end
end
it 'triggers an apt-get update run' do
# set the apt_update exec\'s refreshonly attribute to false
- is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
end
end
end
it 'does not trigger an apt-get update run' do
# don't change the apt_update exec\'s refreshonly attribute. (it should be true)
- is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => true)
end
end
it 'triggers an apt-get update run' do
# set the apt_update exec\'s refreshonly attribute to false
- is_expected.to contain_exec('apt_update').with('refreshonly' => false)
+ expect(subject).to contain_exec('apt_update').with('refreshonly' => false)
end
end
end
end
it {
- is_expected.to contain_file(filename).with('ensure' => 'present',
- 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;},
- 'owner' => 'root',
- 'group' => 'root')
+ expect(subject).to contain_file(filename).with('ensure' => 'present',
+ 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;},
+ 'owner' => 'root',
+ 'group' => 'root')
}
context 'with notify_update = true (default)' do
end
it 'fails' do
- is_expected.to raise_error(%r{pass in content})
+ expect(subject).to raise_error(%r{pass in content})
end
end
end
it {
- is_expected.to contain_file(filename).with('ensure' => 'absent',
- 'owner' => 'root',
- 'group' => 'root')
+ expect(subject).to contain_file(filename).with('ensure' => 'absent',
+ 'owner' => 'root',
+ 'group' => 'root')
}
end
end
describe 'normal operation' do
describe 'default options' do
it {
- is_expected.to contain_apt_key(title).with(id: title,
- ensure: 'present',
- source: nil,
- server: 'keyserver.ubuntu.com',
- content: nil)
+ expect(subject).to contain_apt_key(title).with(id: title,
+ ensure: 'present',
+ source: nil,
+ server: 'keyserver.ubuntu.com',
+ content: nil)
}
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{title} present")
+ expect(subject).to contain_anchor("apt_key #{title} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: GPG_KEY_ID,
- ensure: 'present',
- source: nil,
- server: 'keyserver.ubuntu.com',
- content: nil)
+ expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID,
+ ensure: 'present',
+ source: nil,
+ server: 'keyserver.ubuntu.com',
+ content: nil)
end
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
+ expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- ensure: 'absent',
- source: nil,
- server: 'keyserver.ubuntu.com',
- content: nil)
+ expect(subject).to contain_apt_key(title).with(id: title,
+ ensure: 'absent',
+ source: nil,
+ server: 'keyserver.ubuntu.com',
+ content: nil)
end
it 'contains the apt_key absent anchor' do
- is_expected.to contain_anchor("apt_key #{title} absent")
+ expect(subject).to contain_anchor("apt_key #{title} absent")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(contains_apt_key_example(title))
+ expect(subject).to contain_apt_key(title).with(contains_apt_key_example(title))
end
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{title} present")
+ expect(subject).to contain_anchor("apt_key #{title} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'p-gp.m-it.edu')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'p-gp.m-it.edu')
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'hkp://pgp.mit.edu')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'hkp://pgp.mit.edu')
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'hkp://pgp.mit.edu:80')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'hkp://pgp.mit.edu:80')
end
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
- context 'with incorrect protocol for url' do
+ context 'with incorrect protocol for url' do
let :params do
{
server: 'abc://pgp.mit.edu:80',
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{evaluating a Resource})
+ expect(subject).to raise_error(%r{evaluating a Resource})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a})
+ expect(subject).to raise_error(%r{expects a})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a})
+ expect(subject).to raise_error(%r{expects a})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]})
+ expect(subject).to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]})
end
end
end
it 'contains the duplicate apt::key resource' do
- is_expected.to contain_apt__key('duplicate').with(id: title,
- ensure: 'present')
+ expect(subject).to contain_apt__key('duplicate').with(id: title,
+ ensure: 'present')
end
it 'contains the original apt::key resource' do
- is_expected.to contain_apt__key(title).with(id: title,
- ensure: 'present')
+ expect(subject).to contain_apt__key(title).with(id: title,
+ ensure: 'present')
end
it 'contains the native apt_key' do
- is_expected.to contain_apt_key('duplicate').with(apt_key_example(title))
+ expect(subject).to contain_apt_key('duplicate').with(apt_key_example(title))
end
it 'does not contain the original apt_key' do
- is_expected.not_to contain_apt_key(title)
+ expect(subject).not_to contain_apt_key(title)
end
end
end
it 'informs the user of the impossibility' do
- is_expected.to raise_error(%r{already ensured as absent})
+ expect(subject).to raise_error(%r{already ensured as absent})
end
end
end
describe 'normal operation' do
describe 'default options' do
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(default_apt_key_example(title))
+ expect(subject).to contain_apt_key(title).with(default_apt_key_example(title))
end
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{title} present")
+ expect(subject).to contain_anchor("apt_key #{title} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(title_key_example)
+ expect(subject).to contain_apt_key(title).with(title_key_example)
end
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
+ expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(absent_apt_key(title))
+ expect(subject).to contain_apt_key(title).with(absent_apt_key(title))
end
it 'contains the apt_key absent anchor' do
- is_expected.to contain_anchor("apt_key #{title} absent")
+ expect(subject).to contain_anchor("apt_key #{title} absent")
end
end
end
it 'contains the apt_key with refresh => true' do
- is_expected.to contain_apt_key(title).with(
+ expect(subject).to contain_apt_key(title).with(
ensure: 'present',
refresh: true,
)
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params))
+ expect(subject).to contain_apt_key(title).with(bunch_things_apt_key_example(title, params))
end
it 'contains the apt_key present anchor' do
- is_expected.to contain_anchor("apt_key #{title} present")
+ expect(subject).to contain_anchor("apt_key #{title} present")
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'p-gp.m-it.edu')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'p-gp.m-it.edu')
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'hkp://pgp.mit.edu')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'hkp://pgp.mit.edu')
end
end
end
it 'contains the apt_key' do
- is_expected.to contain_apt_key(title).with(id: title,
- server: 'hkp://pgp.mit.edu:80')
+ expect(subject).to contain_apt_key(title).with(id: title,
+ server: 'hkp://pgp.mit.edu:80')
end
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{evaluating a Resource})
+ expect(subject).to raise_error(%r{evaluating a Resource})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a})
+ expect(subject).to raise_error(%r{expects a})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a match})
+ expect(subject).to raise_error(%r{expects a match})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{expects a})
+ expect(subject).to raise_error(%r{expects a})
end
end
end
it 'fails' do
- is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got})
+ expect(subject).to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got})
end
end
end
end
it 'contains two apt::key resource - duplicate' do
- is_expected.to contain_apt__key('duplicate').with(id: title,
- ensure: 'present')
+ expect(subject).to contain_apt__key('duplicate').with(id: title,
+ ensure: 'present')
end
it 'contains two apt::key resource - title' do
- is_expected.to contain_apt__key(title).with(id: title,
- ensure: 'present')
+ expect(subject).to contain_apt__key(title).with(id: title,
+ ensure: 'present')
end
it 'contains only a single apt_key - duplicate' do
- is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title))
+ expect(subject).to contain_apt_key('duplicate').with(default_apt_key_example(title))
end
it 'contains only a single apt_key - no title' do
- is_expected.not_to contain_apt_key(title)
+ expect(subject).not_to contain_apt_key(title)
end
end
end
it 'informs the user of the impossibility' do
- is_expected.to raise_error(%r{already ensured as absent})
+ expect(subject).to raise_error(%r{already ensured as absent})
end
end
end
end
it 'uses default keyserver' do
- is_expected.to contain_apt_key(title).with_server('keyserver.example.com')
+ expect(subject).to contain_apt_key(title).with_server('keyserver.example.com')
end
end
end
it 'uses default keyserver' do
- is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
+ expect(subject).to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
end
end
end
end
it {
- is_expected.to contain_exec('apt-mark manual mysource')
+ expect(subject).to contain_exec('apt-mark manual mysource')
}
end
end
it do
- is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'})
+ expect(subject).to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'})
end
end
end
it do
- is_expected.to contain_exec("apt-mark manual #{title}")
+ expect(subject).to contain_exec("apt-mark manual #{title}")
end
end
end
end
it do
- is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}})
+ expect(subject).to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}})
end
end
end
it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) }
it {
- is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99)
+ expect(subject).to contain_apt__setting('pref-my_pin').with('priority' => 99)
}
end
end
it {
- is_expected.to contain_apt__setting('pref-my_pin').with('ensure' => 'absent')
+ expect(subject).to contain_apt__setting('pref-my_pin').with('ensure' => 'absent')
}
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects an Integer value, got String})
+ expect(subject).to raise_error(Puppet::Error, %r{expects an Integer value, got String})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{parameter version cannot be used in general form})
+ expect(subject).to raise_error(Puppet::Error, %r{parameter version cannot be used in general form})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive})
+ expect(subject).to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
+ expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
+ expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
end
end
end
it { is_expected.not_to contain_package('python-software-properties') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+ expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('needs', 'substitution'))
}
let(:title) { 'ppa:user/foo' }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+ expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('user', 'foo', 'wily'))
}
it { is_expected.to contain_package('software-properties-common') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+ expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('needs', 'substitution'))
}
it { is_expected.not_to contain_package('python-software-properties') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
+ expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('needs', 'substitution'))
}
it { is_expected.to contain_package('software-properties-common') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+ expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('user', 'foo'))
}
it { is_expected.to contain_package('software-properties-common') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+ expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8080']))
}
it { is_expected.to contain_package('software-properties-common') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+ expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180']))
}
it { is_expected.to contain_package('software-properties-common') }
it {
- is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
+ expect(subject).to contain_exec('add-apt-repository-ppa:user/foo')
.that_notifies('Class[Apt::Update]')
.with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180']))
}
end
it {
- is_expected.to contain_tidy("remove-apt-repository-script-#{title}")
+ expect(subject).to contain_tidy("remove-apt-repository-script-#{title}")
.with('path' => '/opt/puppetlabs/puppet/cache/add-apt-repository-user-ubuntu-foo-trusty.sh')
- is_expected.to contain_tidy("remove-apt-repository-#{title}")
+ expect(subject).to contain_tidy("remove-apt-repository-#{title}")
.with('path' => '/etc/apt/sources.list.d/user-ubuntu-foo-trusty.list')
.that_notifies('Class[Apt::Update]')
}
let(:title) { 'ppa:user/foo' }
it do
- is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+ expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
end
end
let(:title) { 'ppa:user/foo' }
it do
- is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian})
+ expect(subject).to raise_error(Puppet::Error, %r{not currently supported on Debian})
end
end
end
describe 'when using the defaults' do
context 'without source or content' do
it do
- is_expected.to raise_error(Puppet::Error, %r{needs either of })
+ expect(subject).to raise_error(Puppet::Error, %r{needs either of })
end
end
- context 'with title=conf-teddybear ' do
+ context 'with title=conf-teddybear' do
let(:params) { default_params }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
let(:params) { { source: 'puppet:///la/die/dah' } }
it {
- is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
- owner: 'root',
- group: 'root',
- source: params[:source].to_s)
+ expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
+ owner: 'root',
+ group: 'root',
+ source: params[:source].to_s)
}
end
let(:params) { default_params }
it {
- is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
- owner: 'root',
- group: 'root',
- content: params[:content].to_s)
+ expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
+ owner: 'root',
+ group: 'root',
+ content: params[:content].to_s)
}
end
end
let(:params) { default_params.merge(source: 'la') }
it do
- is_expected.to raise_error(Puppet::Error, %r{cannot have both })
+ expect(subject).to raise_error(Puppet::Error, %r{cannot have both })
end
end
let(:params) { default_params }
it do
- is_expected.to raise_error(Puppet::Error, %r{must start with either})
+ expect(subject).to raise_error(Puppet::Error, %r{must start with either})
end
end
let(:params) { default_params.merge(ensure: 'banana') }
it do
- is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
+ expect(subject).to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
end
end
let(:params) { default_params.merge(ensure: 'absent') }
it {
- is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
+ expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
}
end
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
- .without_content(%r{deb-src})
+ expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+ .without_content(%r{deb-src})
}
it {
- is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
- 'priority' => '10',
- 'origin' => 'debian.mirror.iweb.ca')
+ expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
+ 'priority' => '10',
+ 'origin' => 'debian.mirror.iweb.ca')
}
it {
- is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
- 'id' => GPG_KEY_ID)
+ expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
+ 'id' => GPG_KEY_ID)
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent')
+ expect(subject).to contain_apt__setting('list-my_source').with('ensure' => 'absent')
}
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+ expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
end
end
end
context 'with defaults' do
context 'without location' do
it do
- is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location})
+ expect(subject).to raise_error(Puppet::Error, %r{source entry without specifying a location})
end
end
let(:params) { { location: 'hello.there' } }
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
- is_expected.not_to contain_package('apt-transport-https')
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
+ expect(subject).not_to contain_package('apt-transport-https')
}
end
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n})
}
it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') }
it {
- is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
- priority: 1001,
- explanation: 'wishwash',
- release: 'wishwash')
+ expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+ priority: 1001,
+ explanation: 'wishwash',
+ release: 'wishwash')
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
- .without_content(%r{deb-src})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+ .without_content(%r{deb-src})
}
it {
- is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
- priority: '10',
- origin: 'debian.mirror.iweb.ca')
+ expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+ priority: '10',
+ origin: 'debian.mirror.iweb.ca')
}
it {
- is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
- id: GPG_KEY_ID)
+ expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+ id: GPG_KEY_ID)
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
- .without_content(%r{deb-src})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
+ .without_content(%r{deb-src})
}
it {
- is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
- priority: '10',
- origin: 'debian.mirror.iweb.ca')
+ expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
+ priority: '10',
+ origin: 'debian.mirror.iweb.ca')
}
it {
- is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
- id: GPG_KEY_ID,
- server: 'pgp.mit.edu',
- content: 'GPG key content',
- source: 'http://apt.puppetlabs.com/pubkey.gpg',
- weak_ssl: true)
+ expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
+ id: GPG_KEY_ID,
+ server: 'pgp.mit.edu',
+ content: 'GPG key content',
+ source: 'http://apt.puppetlabs.com/pubkey.gpg',
+ weak_ssl: true)
}
end
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source')
+ expect(subject).to contain_apt__setting('list-my_source')
.with(ensure: 'present')
.with_content(%r{# my_source\ndeb \[signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n})
}
end
it {
- is_expected.to contain_apt__setting('list-my_source')
+ expect(subject).to contain_apt__setting('list-my_source')
.with(ensure: 'present')
.with_content(%r{# my_source\ndeb \[arch=amd64 trusted=yes signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n})
}
end
it {
- is_expected.to contain_package('apt-transport-https')
+ expect(subject).to contain_package('apt-transport-https')
}
end
end
it {
- is_expected.to contain_package('apt-transport-https')
+ expect(subject).to contain_package('apt-transport-https')
}
end
end
it {
- is_expected.not_to contain_package('apt-transport-https')
+ expect(subject).not_to contain_package('apt-transport-https')
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n})
}
end
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
}
it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n})
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n})
}
it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there stretch main\n}) }
end
it {
- is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent')
+ expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'absent')
}
end
let(:params) { { location: 'hello.there' } }
it do
- is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
+ expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
end
end
end
it do
- is_expected.to raise_error(Puppet::Error, %r{expects a value})
+ expect(subject).to raise_error(Puppet::Error, %r{expects a value})
end
end
it 'has a value of -1' do
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false)
- is_expected.to eq(-1)
+ expect(subject).to eq(-1)
end
end
allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:mtime).and_return(1_407_660_561)
- is_expected.to eq(1_407_660_561)
+ expect(subject).to eq(1_407_660_561)
end
end
end
it 'apt_key with content set and source nil' do
expect(described_class).to receive(:apt_key).with(['adv', '--no-tty',
'--keyserver',
- :"keyserver.ubuntu.com",
+ :'keyserver.ubuntu.com',
'--recv-keys',
'C105B9DE'])
resource = Puppet::Type::Apt_key.new(name: 'source and content nil',
it 'apt_key content and source nil, options set' do
expect(described_class).to receive(:apt_key).with(['adv', '--no-tty',
'--keyserver',
- :"keyserver.ubuntu.com",
+ :'keyserver.ubuntu.com',
'--keyserver-options',
'jimno',
'--recv-keys',
it "#{key_type} #{value} is valid" do
expect(described_class).to receive(:apt_key).with(array_including('adv', '--no-tty',
'--keyserver',
- :"keyserver.ubuntu.com",
+ :'keyserver.ubuntu.com',
'--recv-keys'))
resource = Puppet::Type::Apt_key.new(name: 'source and content nil',
id: value,