Add the FrozenStrings magic comment
[puppet-modules/puppetlabs-apt.git] / spec / unit / facter / apt_dist_package_updates_spec.rb
1 # frozen_string_literal: true
2
3 require 'spec_helper'
4
5 describe 'apt_package_dist_updates fact' do
6   subject { Facter.fact(:apt_package_dist_updates).value }
7
8   before(:each) { Facter.clear }
9
10   describe 'when apt has no updates' do
11     before(:each) do
12       allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false)
13     end
14     it { is_expected.to be nil }
15   end
16
17   describe 'when apt has updates' do
18     before(:each) do
19       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
20       allow(File).to receive(:executable?) # Stub all other calls
21       allow(Facter::Util::Resolution).to receive(:exec) # Catch all other calls
22       allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
23       allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return('test')
24       allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(true)
25       apt_output = "Inst extremetuxracer [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
26                    "Conf extremetuxracer (2015g-0+deb8u1 Debian:stable-updates [all])\n" \
27                    "Inst planet.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n" \
28                    "Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"
29       allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output)
30     end
31     it { is_expected.to eq(['extremetuxracer', 'planet.rb']) }
32   end
33 end