simp-beaker-helpers 1.34.3 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pr_acceptance.yml +1 -1
  3. data/.github/workflows/pr_tests.yml +6 -7
  4. data/.rubocop.yml +652 -495
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +5 -2
  7. data/lib/simp/beaker_helpers/constants.rb +7 -5
  8. data/lib/simp/beaker_helpers/inspec.rb +52 -55
  9. data/lib/simp/beaker_helpers/snapshot.rb +126 -134
  10. data/lib/simp/beaker_helpers/ssg.rb +33 -34
  11. data/lib/simp/beaker_helpers/version.rb +2 -1
  12. data/lib/simp/beaker_helpers/windows.rb +4 -1
  13. data/lib/simp/beaker_helpers.rb +274 -291
  14. data/lib/simp/rake/beaker.rb +174 -177
  15. data/spec/acceptance/suites/default/check_puppet_version_spec.rb +3 -3
  16. data/spec/acceptance/suites/default/fixture_modules_spec.rb +9 -9
  17. data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +7 -13
  18. data/spec/acceptance/suites/default/pki_tests_spec.rb +10 -16
  19. data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +4 -4
  20. data/spec/acceptance/suites/inspec/00_default_spec.rb +22 -22
  21. data/spec/acceptance/suites/offline/00_default_spec.rb +43 -12
  22. data/spec/acceptance/suites/offline/nodesets/default.yml +1 -3
  23. data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +3 -3
  24. data/spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb +27 -7
  25. data/spec/acceptance/suites/snapshot/10_general_usage_spec.rb +3 -3
  26. data/spec/acceptance/suites/ssg/00_default_spec.rb +20 -18
  27. data/spec/acceptance/suites/windows/00_default_spec.rb +47 -49
  28. data/spec/acceptance/suites/windows/nodesets/default.yml +3 -3
  29. data/spec/acceptance/suites/windows/nodesets/win2012.yml +3 -3
  30. data/spec/acceptance/suites/windows/nodesets/win2016.yml +3 -3
  31. data/spec/acceptance/suites/windows/nodesets/win2019.yml +3 -3
  32. data/spec/lib/simp/beaker_helpers_spec.rb +96 -66
  33. data/spec/spec_helper.rb +51 -53
  34. data/spec/spec_helper_acceptance.rb +17 -22
  35. metadata +5 -5
@@ -6,50 +6,52 @@ require 'beaker/tasks/rake_task'
6
6
  require 'beaker-rspec/rake_task'
7
7
  require 'puppetlabs_spec_helper/tasks/fixtures'
8
8
 
9
+ # Simp::Rake namespace
9
10
  module Simp; end
10
- module Simp::Rake
11
- class Beaker < ::Rake::TaskLib
12
- def initialize(base_dir)
11
+ class Simp::Rake; end
13
12
 
14
- @base_dir = base_dir
15
- @clean_list = []
13
+ # Rake tasks for SIMP Beaker testing
14
+ class Simp::Rake::Beaker < ::Rake::TaskLib
15
+ def initialize(base_dir) # rubocop:disable Lint/MissingSuper
16
+ @base_dir = base_dir
17
+ @clean_list = []
16
18
 
17
- ::CLEAN.include( %{#{@base_dir}/log} )
18
- ::CLEAN.include( %{#{@base_dir}/junit} )
19
- ::CLEAN.include( %{#{@base_dir}/sec_results} )
20
- ::CLEAN.include( %{#{@base_dir}/spec/fixtures/inspec_deps} )
19
+ ::CLEAN.include(%(#{@base_dir}/log))
20
+ ::CLEAN.include(%(#{@base_dir}/junit))
21
+ ::CLEAN.include(%(#{@base_dir}/sec_results))
22
+ ::CLEAN.include(%(#{@base_dir}/spec/fixtures/inspec_deps))
21
23
 
22
- yield self if block_given?
24
+ yield self if block_given?
23
25
 
24
- ::CLEAN.include( @clean_list )
26
+ ::CLEAN.include(@clean_list)
25
27
 
26
- namespace :beaker do
27
- desc <<-EOM
28
+ namespace :beaker do
29
+ desc <<-EOM
28
30
  Run a Beaker test against a specific Nodeset
29
31
  * :nodeset - The nodeset against which you wish to run
30
32
  EOM
31
- task :run, [:nodeset] do |t,args|
32
- fail "You must pass :nodeset to #{t}" unless args[:nodeset]
33
- nodeset = args[:nodeset].strip
33
+ task :run, [:nodeset] do |t, args|
34
+ raise "You must pass :nodeset to #{t}" unless args[:nodeset]
35
+ nodeset = args[:nodeset].strip
34
36
 
35
- old_stdout = $stdout
36
- nodesets = StringIO.new
37
- $stdout = nodesets
37
+ old_stdout = $stdout
38
+ nodesets = StringIO.new
39
+ $stdout = nodesets
38
40
 
39
- Rake::Task['beaker_nodes'].invoke
41
+ Rake::Task['beaker_nodes'].invoke
40
42
 
41
- $stdout = old_stdout
43
+ $stdout = old_stdout
42
44
 
43
- nodesets = nodesets.string.split("\n")
45
+ nodesets = nodesets.string.split("\n")
44
46
 
45
- fail "Nodeset '#{nodeset}' not found. Valid Nodesets:\n#{nodesets.map{|x| x = %( * #{x})}.join(%(\n))}" unless nodesets.include?(nodeset)
47
+ raise "Nodeset '#{nodeset}' not found. Valid Nodesets:\n#{nodesets.map { |x| %( * #{x}) }.join(%(\n))}" unless nodesets.include?(nodeset)
46
48
 
47
- ENV['BEAKER_set'] = nodeset
49
+ ENV['BEAKER_set'] = nodeset
48
50
 
49
- Rake::Task['beaker'].invoke
50
- end
51
+ Rake::Task['beaker'].invoke
52
+ end
51
53
 
52
- desc <<-EOM
54
+ desc <<-EOM
53
55
  Run Beaker test suites.
54
56
  * :suite - A specific suite to run
55
57
  * If you set this to `ALL`, all suites will be run
@@ -108,211 +110,206 @@ module Simp::Rake
108
110
  'default_run' : <true|false> => Default: false
109
111
  ```
110
112
  EOM
111
- task :suites, [:suite, :nodeset] => ['spec_prep'] do |t,args|
112
- suite = args[:suite]
113
- nodeset = args[:nodeset]
113
+ task :suites, [:suite, :nodeset] => ['spec_prep'] do |_t, args|
114
+ suite = args[:suite]
115
+ nodeset = args[:nodeset]
114
116
 
115
- # Record Tasks That Fail
116
- # Need to figure out how to capture the errors
117
- failures = Hash.new
117
+ # Record Tasks That Fail
118
+ # Need to figure out how to capture the errors
119
+ failures = {}
118
120
 
119
- suite_basedir = File.join(@base_dir, 'spec/acceptance/suites')
121
+ suite_basedir = File.join(@base_dir, 'spec/acceptance/suites')
120
122
 
121
- if ENV['BEAKER_suite_basedir']
122
- suite_basedir = ENV['BEAKER_suite_basedir']
123
- end
123
+ if ENV['BEAKER_suite_basedir']
124
+ suite_basedir = ENV['BEAKER_suite_basedir']
125
+ end
124
126
 
125
- raise("Error: Suites Directory at '#{suite_basedir}'!") unless File.directory?(suite_basedir)
126
-
127
- if suite && (suite != 'ALL')
128
- unless File.directory?(File.join(suite_basedir, suite))
129
- STDERR.puts("Error: Could not find suite '#{suite}'")
130
- STDERR.puts("Available Suites:")
131
- STDERR.puts(' * ' + Dir.glob(
132
- File.join(suite_basedir, '*')).sort.map{ |x|
133
- File.basename(x)
134
- }.join("\n * ")
135
- )
136
- exit(1)
137
- end
127
+ raise("Error: Suites Directory at '#{suite_basedir}'!") unless File.directory?(suite_basedir)
128
+
129
+ if suite && (suite != 'ALL')
130
+ unless File.directory?(File.join(suite_basedir, suite))
131
+ STDERR.puts("Error: Could not find suite '#{suite}'")
132
+ STDERR.puts('Available Suites:')
133
+ STDERR.puts(' * ' + Dir.glob(
134
+ File.join(suite_basedir, '*'),
135
+ ).sort.map { |x|
136
+ File.basename(x)
137
+ }.join("\n * "))
138
+ exit(1)
138
139
  end
140
+ end
139
141
 
140
- suite_config = {
141
- 'fail_fast' => true
142
- }
143
- suite_config_metadata_path = File.join(suite_basedir, 'config.yml')
144
- if File.file?(suite_config_metadata_path)
145
- suite_config.merge!(YAML.load_file(suite_config_metadata_path))
146
- end
142
+ suite_config = {
143
+ 'fail_fast' => true
144
+ }
145
+ suite_config_metadata_path = File.join(suite_basedir, 'config.yml')
146
+ if File.file?(suite_config_metadata_path)
147
+ suite_config.merge!(YAML.load_file(suite_config_metadata_path))
148
+ end
147
149
 
148
- suites = Hash.new
150
+ suites = {}
149
151
 
150
- if suite && (suite != 'ALL')
151
- suites[suite] = Hash.new
152
- # If a suite was set, make sure it runs.
153
- suites[suite]['default_run'] = true
154
- else
155
- Dir.glob(File.join(suite_basedir,'*')) do |file|
156
- if File.directory?(file)
157
- suites[File.basename(file)] = Hash.new
152
+ if suite && (suite != 'ALL')
153
+ suites[suite] = {}
154
+ # If a suite was set, make sure it runs.
155
+ suites[suite]['default_run'] = true
156
+ else
157
+ Dir.glob(File.join(suite_basedir, '*')) do |file|
158
+ if File.directory?(file)
159
+ suites[File.basename(file)] = {}
158
160
 
159
- if suite == 'ALL'
160
- suites[File.basename(file)]['default_run'] = true
161
- end
161
+ if suite == 'ALL'
162
+ suites[File.basename(file)]['default_run'] = true
162
163
  end
163
164
  end
164
165
  end
166
+ end
165
167
 
166
- suites.keys.each do |ste|
167
- suites[ste]['name'] = ste
168
- suites[ste]['path'] = File.join(suite_basedir, ste)
168
+ suites.each_key do |ste|
169
+ suites[ste]['name'] = ste
170
+ suites[ste]['path'] = File.join(suite_basedir, ste)
169
171
 
170
- metadata_path = File.join(suites[ste]['path'], 'metadata.yml')
171
- if File.file?(metadata_path)
172
- suites[ste]['metadata'] = YAML.load_file(metadata_path)
173
- end
172
+ metadata_path = File.join(suites[ste]['path'], 'metadata.yml')
173
+ if File.file?(metadata_path)
174
+ suites[ste]['metadata'] = YAML.load_file(metadata_path)
175
+ end
174
176
 
175
- unless File.directory?(File.join(suites[ste]['path'],'nodesets'))
176
- Dir.chdir(suites[ste]['path']) do
177
- if File.directory?('../../nodesets')
178
- FileUtils.ln_s('../../nodesets', 'nodesets')
179
- end
177
+ unless File.directory?(File.join(suites[ste]['path'], 'nodesets'))
178
+ Dir.chdir(suites[ste]['path']) do
179
+ if File.directory?('../../nodesets')
180
+ FileUtils.ln_s('../../nodesets', 'nodesets')
180
181
  end
181
182
  end
183
+ end
182
184
 
183
- suites[ste].merge!(suites[ste]['metadata']) if suites[ste]['metadata']
185
+ suites[ste].merge!(suites[ste]['metadata']) if suites[ste]['metadata']
184
186
 
185
- # Ensure that the 'default' suite runs unless explicitly disabled.
186
- if suites['default']
187
- if ( suites['default']['default_run'].nil? ) || ( suites['default']['default_run'] == true )
188
- suites['default']['default_run'] = true
189
- end
190
- end
187
+ # Ensure that the 'default' suite runs unless explicitly disabled.
188
+ next unless suites['default']
189
+ if suites['default']['default_run'].nil? || (suites['default']['default_run'] == true)
190
+ suites['default']['default_run'] = true
191
191
  end
192
+ end
192
193
 
193
- raise("Error: No Suites Found in '#{suite_basedir}'!") if suites.empty?
194
-
195
- # Need to ensure that 'default' is first
196
- ordered_suites = suites.keys.sort
197
- default_suite = ordered_suites.delete('default')
198
- ordered_suites.unshift(default_suite) if default_suite
194
+ raise("Error: No Suites Found in '#{suite_basedir}'!") if suites.empty?
199
195
 
200
- suite_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
201
- ordered_suites.each do |ste|
196
+ # Need to ensure that 'default' is first
197
+ ordered_suites = suites.keys.sort
198
+ default_suite = ordered_suites.delete('default')
199
+ ordered_suites.unshift(default_suite) if default_suite
202
200
 
203
- next unless (suites[ste]['default_run'] == true)
201
+ suite_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
202
+ ordered_suites.each do |ste|
203
+ next unless suites[ste]['default_run'] == true
204
204
 
205
- name = suites[ste]['name']
205
+ name = suites[ste]['name']
206
206
 
207
- $stdout.puts("\n\n=== Suite '#{name}' Starting ===\n\n")
207
+ $stdout.puts("\n\n=== Suite '#{name}' Starting ===\n\n")
208
208
 
209
- nodesets = Array.new
210
- nodeset_path = File.join(suites[ste]['path'],'nodesets')
209
+ nodesets = []
210
+ nodeset_path = File.join(suites[ste]['path'], 'nodesets')
211
211
 
212
- if nodeset
213
- if nodeset == 'ALL'
214
- nodesets = Dir.glob(File.join(nodeset_path, '*.yml'))
212
+ if nodeset
213
+ if nodeset == 'ALL'
214
+ nodesets = Dir.glob(File.join(nodeset_path, '*.yml'))
215
215
 
216
- # Make sure we run the default set first
217
- default_set = nodesets.delete(File.join(nodeset_path, 'default.yml'))
218
- nodesets.unshift(default_set) if default_set
219
- else
220
- nodeset.split(':').each do |tgt_nodeset|
221
- nodesets << File.join(nodeset_path, "#{tgt_nodeset.strip}.yml")
222
- end
223
- end
216
+ # Make sure we run the default set first
217
+ default_set = nodesets.delete(File.join(nodeset_path, 'default.yml'))
218
+ nodesets.unshift(default_set) if default_set
224
219
  else
225
- nodesets << File.join(nodeset_path, 'default.yml')
220
+ nodeset.split(':').each do |tgt_nodeset|
221
+ nodesets << File.join(nodeset_path, "#{tgt_nodeset.strip}.yml")
222
+ end
226
223
  end
224
+ else
225
+ nodesets << File.join(nodeset_path, 'default.yml')
226
+ end
227
227
 
228
- refined_nodesets = []
229
-
230
- nodesets.each do |nodeset_yml|
231
- parsed_nodeset = ::Beaker::Options::HostsFileParser.parse_hosts_file(nodeset_yml)
228
+ refined_nodesets = []
232
229
 
233
- # Default to multi-node testing for backwards compatibility
234
- multi_node = (parsed_nodeset[:multi_node] == false ? false: true)
230
+ nodesets.each do |nodeset_yml|
231
+ parsed_nodeset = ::Beaker::Options::HostsFileParser.parse_hosts_file(nodeset_yml)
235
232
 
236
- if multi_node
237
- refined_nodesets.push(nodeset_yml)
238
- else
239
- parsed_nodeset_hosts = parsed_nodeset.delete(:HOSTS)
233
+ # Default to multi-node testing for backwards compatibility
234
+ multi_node = ((parsed_nodeset[:multi_node] == false) ? false : true)
240
235
 
241
- parsed_nodeset_hosts.each do |k,v|
236
+ if multi_node
237
+ refined_nodesets.push(nodeset_yml)
238
+ else
239
+ parsed_nodeset_hosts = parsed_nodeset.delete(:HOSTS)
242
240
 
243
- v[:roles] ||= []
244
- v[:roles] |= ['default']
241
+ parsed_nodeset_hosts.each do |k, v|
242
+ v[:roles] ||= []
243
+ v[:roles] |= ['default']
245
244
 
246
- tmp_nodeset = {
247
- :HOSTS => { k => v },
248
- :CONFIG => parsed_nodeset
249
- }
245
+ tmp_nodeset = {
246
+ HOSTS: { k => v },
247
+ CONFIG: parsed_nodeset
248
+ }
250
249
 
251
- tmp_nodeset_file = Tempfile.new("nodeset_#{k}-")
252
- tmp_nodeset_file.write(tmp_nodeset.to_yaml)
253
- tmp_nodeset_file.close
250
+ tmp_nodeset_file = Tempfile.new("nodeset_#{k}-")
251
+ tmp_nodeset_file.write(tmp_nodeset.to_yaml)
252
+ tmp_nodeset_file.close
254
253
 
255
- refined_nodesets.push(tmp_nodeset_file.path)
254
+ refined_nodesets.push(tmp_nodeset_file.path)
256
255
 
257
- at_exit do
258
- if tmp_nodeset_file && File.exist?(tmp_nodeset_file.path)
259
- tmp_nodeset_file.close
260
- tmp_nodeset_file.unlink
261
- end
256
+ at_exit do
257
+ if tmp_nodeset_file && File.exist?(tmp_nodeset_file.path)
258
+ tmp_nodeset_file.close
259
+ tmp_nodeset_file.unlink
262
260
  end
263
261
  end
264
262
  end
265
263
  end
264
+ end
266
265
 
267
- refined_nodesets.sort.each do |nodeset_yml|
268
- unless File.file?(nodeset_yml)
269
- # Get here if user has specified a non-existent nodeset or the
270
- # implied `default` nodeset does not exist.
271
- if suite_config['fail_fast']
272
- fail("*** Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found ***")
273
- else
274
- $stdout.puts("=== Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found, Skipping ===")
275
- next
276
- end
277
- end
266
+ refined_nodesets.sort.each do |nodeset_yml|
267
+ unless File.file?(nodeset_yml)
268
+ # Get here if user has specified a non-existent nodeset or the
269
+ # implied `default` nodeset does not exist.
270
+ raise("*** Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found ***") if suite_config['fail_fast']
278
271
 
279
- ENV['BEAKER_setfile'] = nodeset_yml
272
+ $stdout.puts("=== Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found, Skipping ===")
273
+ next
280
274
 
281
- Rake::Task[:beaker].clear
282
- RSpec::Core::RakeTask.new(:beaker) do |tsk|
283
- tsk.rspec_opts = ['--color']
284
- tsk.pattern = File.join(suites[ste]['path'])
285
- end
275
+ end
276
+
277
+ ENV['BEAKER_setfile'] = nodeset_yml
286
278
 
287
- current_suite_task = Rake::Task[:beaker]
279
+ Rake::Task[:beaker].clear
280
+ RSpec::Core::RakeTask.new(:beaker) do |tsk|
281
+ tsk.rspec_opts = ['--color']
282
+ tsk.pattern = File.join(suites[ste]['path'])
283
+ end
288
284
 
289
- if suite_config['fail_fast'] == true
285
+ current_suite_task = Rake::Task[:beaker]
286
+
287
+ if suite_config['fail_fast'] == true
288
+ current_suite_task.execute
289
+ else
290
+ begin
290
291
  current_suite_task.execute
291
- else
292
- begin
293
- current_suite_task.execute
294
- rescue SystemExit
295
- failures[suites[ste]['name']] = {
296
- 'path' => suites[ste]['path'],
297
- 'nodeset' => File.basename(nodeset_yml, '.yml')
298
- }
299
- end
292
+ rescue SystemExit
293
+ failures[suites[ste]['name']] = {
294
+ 'path' => suites[ste]['path'],
295
+ 'nodeset' => File.basename(nodeset_yml, '.yml')
296
+ }
300
297
  end
301
-
302
- $stdout.puts("\n\n=== Suite '#{name}' Complete ===\n\n")
303
298
  end
299
+
300
+ $stdout.puts("\n\n=== Suite '#{name}' Complete ===\n\n")
304
301
  end
305
- suite_end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
302
+ end
303
+ suite_end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
306
304
 
307
- suite_run_time = ((suite_end_time - suite_start_time)/60).round(2)
305
+ suite_run_time = ((suite_end_time - suite_start_time) / 60).round(2)
308
306
 
309
- $stdout.puts("== Total Runtime: #{suite_run_time} minutes ==\n\n")
307
+ $stdout.puts("== Total Runtime: #{suite_run_time} minutes ==\n\n")
310
308
 
311
- unless failures.keys.empty?
312
- $stdout.puts("The following tests had failures:")
313
- failures.keys.sort.each do |ste|
314
- $stdout.puts(" * #{ste} => #{failures[ste]['path']} on #{failures[ste]['nodeset']}")
315
- end
309
+ unless failures.keys.empty?
310
+ $stdout.puts('The following tests had failures:')
311
+ failures.keys.sort.each do |ste|
312
+ $stdout.puts(" * #{ste} => #{failures[ste]['path']} on #{failures[ste]['nodeset']}")
316
313
  end
317
314
  end
318
315
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper_acceptance'
2
2
 
3
3
  unless ENV['PUPPET_VERSION'] || ENV['BEAKER_PUPPET_COLLECTION']
4
- fail('You must set either PUPPET_VERSION or BEAKER_PUPPET_COLLECTION as an environment variable')
4
+ raise('You must set either PUPPET_VERSION or BEAKER_PUPPET_COLLECTION as an environment variable')
5
5
  end
6
6
 
7
7
  if ENV['BEAKER_PUPPET_COLLECTION']
8
- target_version = ENV['BEAKER_PUPPET_COLLECTION'][/(\d+)$/,1]
8
+ target_version = ENV['BEAKER_PUPPET_COLLECTION'][%r{(\d+)$}, 1]
9
9
  elsif ENV['PUPPET_VERSION']
10
10
  target_version = ENV['PUPPET_VERSION'].split('.').first
11
11
  end
@@ -15,7 +15,7 @@ hosts.each do |host|
15
15
  context "on #{host}" do
16
16
  client_puppet_version = on(host, 'puppet --version').output.lines.last.strip
17
17
 
18
- it "should be running puppet version #{target_version}" do
18
+ it "is running puppet version #{target_version}" do
19
19
  expect(Gem::Version.new(client_puppet_version)).to be >= Gem::Version.new(target_version)
20
20
  end
21
21
  end
@@ -3,29 +3,29 @@ require 'spec_helper_acceptance'
3
3
  context 'after copy_fixture_modules_to( hosts )' do
4
4
  before(:all) do
5
5
  # This should automatically run pluginsync_on hosts
6
- copy_fixture_modules_to( hosts )
6
+ copy_fixture_modules_to(hosts)
7
7
  end
8
8
 
9
9
  describe "fact_on(default,'root_home')" do
10
- it 'should not return value of `root_home`' do
10
+ it 'does not return value of `root_home`' do
11
11
  expect(fact_on(default, 'root_home').to_s).to eq ''
12
12
  end
13
13
  end
14
14
 
15
15
  describe "pfact_on(default,'root_home')" do
16
- it 'should return value of `root_home`' do
16
+ it 'returns value of `root_home`' do
17
17
  expect(pfact_on(default, 'root_home')).to eq '/root'
18
18
  end
19
19
  end
20
20
 
21
21
  describe "pfact_on(default,'os.release.major')" do
22
- it 'should return the value of `os.release.major`' do
23
- expect(pfact_on(default, 'os.release.major')).to match(/.+/)
22
+ it 'returns the value of `os.release.major`' do
23
+ expect(pfact_on(default, 'os.release.major')).to match(%r{.+})
24
24
  end
25
25
  end
26
26
 
27
27
  describe "pfact_on(default,'os.release.foo')" do
28
- it 'should not return the value of `os.release.foo`' do
28
+ it 'does not return the value of `os.release.foo`' do
29
29
  expect(pfact_on(default, 'os.release.foo').to_s).to eq ''
30
30
  end
31
31
  end
@@ -33,13 +33,13 @@ context 'after copy_fixture_modules_to( hosts )' do
33
33
  describe "pfact_on(default,'fips_enabled')" do
34
34
  expected = (ENV['BEAKER_fips'] == 'yes')
35
35
 
36
- it 'should return false' do
36
+ it 'returns false' do
37
37
  expect(pfact_on(default, 'fips_enabled')).to eq expected
38
38
  end
39
39
  end
40
40
 
41
- describe "pfact_on returns a hash" do
42
- it 'should return a Hash' do
41
+ describe 'pfact_on returns a hash' do
42
+ it 'returns a Hash' do
43
43
  expect(pfact_on(default, 'os')).to be_a(Hash)
44
44
  end
45
45
  end
@@ -7,7 +7,7 @@ hosts.each do |host|
7
7
  end
8
8
 
9
9
  describe '#install_simp_repos' do
10
- it 'should install yum utils' do
10
+ it 'installs yum utils' do
11
11
  host.install_package('yum-utils')
12
12
  end
13
13
 
@@ -15,11 +15,8 @@ hosts.each do |host|
15
15
  before(:all) do
16
16
  install_simp_repos(host)
17
17
  rescue => e
18
- if expect_failures
19
- warn e.message
20
- else
21
- raise e
22
- end
18
+ raise e unless expect_failures
19
+ warn e.message
23
20
  end
24
21
 
25
22
  it 'enables the correct repos' do
@@ -43,13 +40,10 @@ hosts.each do |host|
43
40
 
44
41
  context 'when passed a disabled list ' do
45
42
  before(:all) do
46
- install_simp_repos(host, ['simp-community-simp'] )
43
+ install_simp_repos(host, ['simp-community-simp'])
47
44
  rescue => e
48
- if expect_failures
49
- warn e.message
50
- else
51
- raise e
52
- end
45
+ raise e unless expect_failures
46
+ warn e.message
53
47
  end
54
48
 
55
49
  it 'enables the correct repos' do
@@ -58,7 +52,7 @@ hosts.each do |host|
58
52
  end
59
53
 
60
54
  it 'disables the correct repos' do
61
- on(host, 'yum -y list simp', :acceptable_exit_codes => [1])
55
+ on(host, 'yum -y list simp', acceptable_exit_codes: [1])
62
56
  end
63
57
  end
64
58
  end
@@ -1,42 +1,37 @@
1
1
  require 'spec_helper_acceptance'
2
2
  require 'tmpdir'
3
3
 
4
-
5
4
  context 'PKI operations' do
6
-
7
5
  context 'after run_fake_pki_ca_on(default,hosts)' do
8
6
  before(:all) do
9
- copy_fixture_modules_to( hosts )
7
+ copy_fixture_modules_to(hosts)
10
8
  end
11
9
 
12
10
  shared_examples_for 'a correctly copied keydist/ tree' do |test_dir|
13
11
  it 'correctly copies keydist/ tree' do
14
- on(default, "ls -d #{test_dir}" +
15
- " #{test_dir}/cacerts" +
16
- " #{test_dir}/cacerts/cacert_*.pem"
17
- )
12
+ on(default, "ls -d #{test_dir}" \
13
+ " #{test_dir}/cacerts" \
14
+ " #{test_dir}/cacerts/cacert_*.pem")
18
15
 
19
16
  hosts.each do |host|
20
17
  name = host.node_name
21
- on(default, "ls -d #{test_dir}/#{name}/cacerts" +
22
- " #{test_dir}/#{name}/#{name}.pem" +
23
- " #{test_dir}/#{name}/#{name}.pub" +
24
- " #{test_dir}/cacerts/cacert_*.pem"
25
- )
18
+ on(default, "ls -d #{test_dir}/#{name}/cacerts" \
19
+ " #{test_dir}/#{name}/#{name}.pem" \
20
+ " #{test_dir}/#{name}/#{name}.pub" \
21
+ " #{test_dir}/cacerts/cacert_*.pem")
26
22
  end
27
23
  end
28
24
  end
29
25
 
30
26
  describe 'a Fake CA under /root' do
31
27
  tmp_keydist_dir = Dir.mktmpdir 'simp-beaker-helpers__pki-tests'
32
- run_fake_pki_ca_on( default, hosts, tmp_keydist_dir )
28
+ run_fake_pki_ca_on(default, hosts, tmp_keydist_dir)
33
29
 
34
- it 'should create /root/pki' do
30
+ it 'creates /root/pki' do
35
31
  on(default, 'test -d /root/pki')
36
32
  end
37
33
 
38
34
  it_behaves_like 'a correctly copied keydist/ tree', '/root/pki/keydist'
39
-
40
35
  end
41
36
 
42
37
  describe 'after copy_keydist_to' do
@@ -50,6 +45,5 @@ context 'PKI operations' do
50
45
  copy_keydist_to(default, test_dir)
51
46
  it_behaves_like 'a correctly copied keydist/ tree', test_dir
52
47
  end
53
-
54
48
  end
55
49
  end
@@ -25,7 +25,7 @@ new_fixtures['fixtures']['repositories']['augeasproviders_grub'] = 'https://gith
25
25
  new_fixtures['fixtures']['repositories']['simplib'] = 'https://github.com/simp/pupmod-simp-simplib'
26
26
  new_fixtures['fixtures']['repositories']['stdlib'] = 'https://github.com/simp/puppetlabs-stdlib'
27
27
 
28
- File.open(alt_fixtures, 'w'){ |fh| fh.puts(new_fixtures.to_yaml) }
28
+ File.open(alt_fixtures, 'w') { |fh| fh.puts(new_fixtures.to_yaml) }
29
29
 
30
30
  ScrubFixtures.new
31
31
 
@@ -34,12 +34,12 @@ ENV['FIXTURES_YML'] = alt_fixtures
34
34
 
35
35
  beaker_gem_options = ENV['BEAKER_GEM_OPTIONS']
36
36
 
37
- Bundler.with_clean_env{
37
+ Bundler.with_clean_env do
38
38
  ENV['BEAKER_GEM_OPTIONS'] = beaker_gem_options
39
39
  ENV['FIXTURES_YML'] = alt_fixtures
40
40
 
41
- %x{bundle exec rake spec_prep}
42
- }
41
+ `bundle exec rake spec_prep`
42
+ end
43
43
 
44
44
  require 'spec_helper_acceptance'
45
45