|
18 | 18 | Puppet::Util::Execution::ProcessOutput.new('', 0) |
19 | 19 | end |
20 | 20 |
|
21 | | - osfamilies = [ 'archlinux', 'coreos', 'gentoo' ] |
| 21 | + osfamilies = %w[archlinux coreos gentoo] |
22 | 22 |
|
23 | 23 | osfamilies.each do |osfamily| |
24 | 24 | it "should be the default provider on #{osfamily}" do |
|
38 | 38 | end |
39 | 39 | end |
40 | 40 |
|
41 | | - [ 4, 5, 6 ].each do |ver| |
| 41 | + [4, 5, 6].each do |ver| |
42 | 42 | it "should not be the default provider on rhel#{ver}" do |
43 | 43 | allow(Facter).to receive(:value).with('os.family').and_return(:redhat) |
44 | 44 | allow(Facter).to receive(:value).with('os.name').and_return(:redhat) |
|
47 | 47 | end |
48 | 48 | end |
49 | 49 |
|
50 | | - [ 17, 18, 19, 20, 21, 22, 23 ].each do |ver| |
| 50 | + (17..23).to_a.each do |ver| |
51 | 51 | it "should be the default provider on fedora#{ver}" do |
52 | 52 | allow(Facter).to receive(:value).with('os.family').and_return(:redhat) |
53 | 53 | allow(Facter).to receive(:value).with('os.name').and_return(:fedora) |
|
56 | 56 | end |
57 | 57 | end |
58 | 58 |
|
59 | | - [ 2, 2023 ].each do |ver| |
| 59 | + [2, 2023].each do |ver| |
60 | 60 | it "should be the default provider on Amazon Linux #{ver}" do |
61 | 61 | allow(Facter).to receive(:value).with('os.family').and_return(:redhat) |
62 | 62 | allow(Facter).to receive(:value).with('os.name').and_return(:amazon) |
|
144 | 144 | expect(provider_class).not_to be_default |
145 | 145 | end |
146 | 146 |
|
147 | | - [ '15.04', '15.10', '16.04', '16.10', '17.04', '17.10', '18.04' ].each do |ver| |
| 147 | + %w[15.04 15.10 16.04 16.10 17.04 17.10 18.04].each do |ver| |
148 | 148 | it "should be the default provider on ubuntu#{ver}" do |
149 | 149 | allow(Facter).to receive(:value).with('os.family').and_return(:debian) |
150 | 150 | allow(Facter).to receive(:value).with('os.name').and_return(:ubuntu) |
|
153 | 153 | end |
154 | 154 | end |
155 | 155 |
|
156 | | - [ '10', '11', '12', '13', '14', '15', '16', '17' ].each do |ver| |
| 156 | + ('10'..'17').to_a.each do |ver| |
157 | 157 | it "should not be the default provider on LinuxMint#{ver}" do |
158 | 158 | allow(Facter).to receive(:value).with('os.family').and_return(:debian) |
159 | 159 | allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint) |
|
162 | 162 | end |
163 | 163 | end |
164 | 164 |
|
165 | | - [ '18', '19' ].each do |ver| |
| 165 | + ['18', '19'].each do |ver| |
166 | 166 | it "should be the default provider on LinuxMint#{ver}" do |
167 | 167 | allow(Facter).to receive(:value).with('os.family').and_return(:debian) |
168 | 168 | allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint) |
|
171 | 171 | end |
172 | 172 | end |
173 | 173 |
|
174 | | - [:enabled?, :daemon_reload?, :enable, :disable, :start, :stop, :status, :restart].each do |method| |
| 174 | + %i[enabled? daemon_reload? enable disable start stop status restart].each do |method| |
175 | 175 | it "should have a #{method} method" do |
176 | 176 | expect(provider).to respond_to(method) |
177 | 177 | end |
|
335 | 335 |
|
336 | 336 | it "should consider nonexistent services to be disabled" do |
337 | 337 | provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'doesnotexist')) |
| 338 | + allow(Facter).to receive(:value).with('os.family').and_return('debian') |
338 | 339 | expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'doesnotexist'], {:failonfail => false}) |
339 | 340 | .and_return(Puppet::Util::Execution::ProcessOutput.new("", 1)) |
340 | 341 | expect(provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", "doesnotexist", "start"], {:failonfail => false}) |
|
0 commit comments