simp-beaker-helpers 1.34.3 → 1.35.1

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 +8 -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 +175 -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,53 @@ require 'beaker/tasks/rake_task'
6
6
  require 'beaker-rspec/rake_task'
7
7
  require 'puppetlabs_spec_helper/tasks/fixtures'
8
8
 
9
+ # Simp namespace
9
10
  module Simp; end
10
- module Simp::Rake
11
- class Beaker < ::Rake::TaskLib
12
- def initialize(base_dir)
11
+ # Simp::Rake namespace
12
+ module Simp::Rake; end
13
13
 
14
- @base_dir = base_dir
15
- @clean_list = []
14
+ # Rake tasks for SIMP Beaker testing
15
+ class Simp::Rake::Beaker < ::Rake::TaskLib
16
+ def initialize(base_dir) # rubocop:disable Lint/MissingSuper
17
+ @base_dir = base_dir
18
+ @clean_list = []
16
19
 
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} )
20
+ ::CLEAN.include(%(#{@base_dir}/log))
21
+ ::CLEAN.include(%(#{@base_dir}/junit))
22
+ ::CLEAN.include(%(#{@base_dir}/sec_results))
23
+ ::CLEAN.include(%(#{@base_dir}/spec/fixtures/inspec_deps))
21
24
 
22
- yield self if block_given?
25
+ yield self if block_given?
23
26
 
24
- ::CLEAN.include( @clean_list )
27
+ ::CLEAN.include(@clean_list)
25
28
 
26
- namespace :beaker do
27
- desc <<-EOM
29
+ namespace :beaker do
30
+ desc <<-EOM
28
31
  Run a Beaker test against a specific Nodeset
29
32
  * :nodeset - The nodeset against which you wish to run
30
33
  EOM
31
- task :run, [:nodeset] do |t,args|
32
- fail "You must pass :nodeset to #{t}" unless args[:nodeset]
33
- nodeset = args[:nodeset].strip
34
+ task :run, [:nodeset] do |t, args|
35
+ raise "You must pass :nodeset to #{t}" unless args[:nodeset]
36
+ nodeset = args[:nodeset].strip
34
37
 
35
- old_stdout = $stdout
36
- nodesets = StringIO.new
37
- $stdout = nodesets
38
+ old_stdout = $stdout
39
+ nodesets = StringIO.new
40
+ $stdout = nodesets
38
41
 
39
- Rake::Task['beaker_nodes'].invoke
42
+ Rake::Task['beaker_nodes'].invoke
40
43
 
41
- $stdout = old_stdout
44
+ $stdout = old_stdout
42
45
 
43
- nodesets = nodesets.string.split("\n")
46
+ nodesets = nodesets.string.split("\n")
44
47
 
45
- fail "Nodeset '#{nodeset}' not found. Valid Nodesets:\n#{nodesets.map{|x| x = %( * #{x})}.join(%(\n))}" unless nodesets.include?(nodeset)
48
+ raise "Nodeset '#{nodeset}' not found. Valid Nodesets:\n#{nodesets.map { |x| %( * #{x}) }.join(%(\n))}" unless nodesets.include?(nodeset)
46
49
 
47
- ENV['BEAKER_set'] = nodeset
50
+ ENV['BEAKER_set'] = nodeset
48
51
 
49
- Rake::Task['beaker'].invoke
50
- end
52
+ Rake::Task['beaker'].invoke
53
+ end
51
54
 
52
- desc <<-EOM
55
+ desc <<-EOM
53
56
  Run Beaker test suites.
54
57
  * :suite - A specific suite to run
55
58
  * If you set this to `ALL`, all suites will be run
@@ -108,211 +111,206 @@ module Simp::Rake
108
111
  'default_run' : <true|false> => Default: false
109
112
  ```
110
113
  EOM
111
- task :suites, [:suite, :nodeset] => ['spec_prep'] do |t,args|
112
- suite = args[:suite]
113
- nodeset = args[:nodeset]
114
+ task :suites, [:suite, :nodeset] => ['spec_prep'] do |_t, args|
115
+ suite = args[:suite]
116
+ nodeset = args[:nodeset]
114
117
 
115
- # Record Tasks That Fail
116
- # Need to figure out how to capture the errors
117
- failures = Hash.new
118
+ # Record Tasks That Fail
119
+ # Need to figure out how to capture the errors
120
+ failures = {}
118
121
 
119
- suite_basedir = File.join(@base_dir, 'spec/acceptance/suites')
122
+ suite_basedir = File.join(@base_dir, 'spec/acceptance/suites')
120
123
 
121
- if ENV['BEAKER_suite_basedir']
122
- suite_basedir = ENV['BEAKER_suite_basedir']
123
- end
124
+ if ENV['BEAKER_suite_basedir']
125
+ suite_basedir = ENV['BEAKER_suite_basedir']
126
+ end
124
127
 
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
128
+ raise("Error: Suites Directory at '#{suite_basedir}'!") unless File.directory?(suite_basedir)
129
+
130
+ if suite && (suite != 'ALL')
131
+ unless File.directory?(File.join(suite_basedir, suite))
132
+ STDERR.puts("Error: Could not find suite '#{suite}'")
133
+ STDERR.puts('Available Suites:')
134
+ STDERR.puts(' * ' + Dir.glob(
135
+ File.join(suite_basedir, '*'),
136
+ ).sort.map { |x|
137
+ File.basename(x)
138
+ }.join("\n * "))
139
+ exit(1)
138
140
  end
141
+ end
139
142
 
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
143
+ suite_config = {
144
+ 'fail_fast' => true
145
+ }
146
+ suite_config_metadata_path = File.join(suite_basedir, 'config.yml')
147
+ if File.file?(suite_config_metadata_path)
148
+ suite_config.merge!(YAML.load_file(suite_config_metadata_path))
149
+ end
147
150
 
148
- suites = Hash.new
151
+ suites = {}
149
152
 
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
153
+ if suite && (suite != 'ALL')
154
+ suites[suite] = {}
155
+ # If a suite was set, make sure it runs.
156
+ suites[suite]['default_run'] = true
157
+ else
158
+ Dir.glob(File.join(suite_basedir, '*')) do |file|
159
+ if File.directory?(file)
160
+ suites[File.basename(file)] = {}
158
161
 
159
- if suite == 'ALL'
160
- suites[File.basename(file)]['default_run'] = true
161
- end
162
+ if suite == 'ALL'
163
+ suites[File.basename(file)]['default_run'] = true
162
164
  end
163
165
  end
164
166
  end
167
+ end
165
168
 
166
- suites.keys.each do |ste|
167
- suites[ste]['name'] = ste
168
- suites[ste]['path'] = File.join(suite_basedir, ste)
169
+ suites.each_key do |ste|
170
+ suites[ste]['name'] = ste
171
+ suites[ste]['path'] = File.join(suite_basedir, ste)
169
172
 
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
173
+ metadata_path = File.join(suites[ste]['path'], 'metadata.yml')
174
+ if File.file?(metadata_path)
175
+ suites[ste]['metadata'] = YAML.load_file(metadata_path)
176
+ end
174
177
 
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
178
+ unless File.directory?(File.join(suites[ste]['path'], 'nodesets'))
179
+ Dir.chdir(suites[ste]['path']) do
180
+ if File.directory?('../../nodesets')
181
+ FileUtils.ln_s('../../nodesets', 'nodesets')
180
182
  end
181
183
  end
184
+ end
182
185
 
183
- suites[ste].merge!(suites[ste]['metadata']) if suites[ste]['metadata']
186
+ suites[ste].merge!(suites[ste]['metadata']) if suites[ste]['metadata']
184
187
 
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
188
+ # Ensure that the 'default' suite runs unless explicitly disabled.
189
+ next unless suites['default']
190
+ if suites['default']['default_run'].nil? || (suites['default']['default_run'] == true)
191
+ suites['default']['default_run'] = true
191
192
  end
193
+ end
192
194
 
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
195
+ raise("Error: No Suites Found in '#{suite_basedir}'!") if suites.empty?
199
196
 
200
- suite_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
201
- ordered_suites.each do |ste|
197
+ # Need to ensure that 'default' is first
198
+ ordered_suites = suites.keys.sort
199
+ default_suite = ordered_suites.delete('default')
200
+ ordered_suites.unshift(default_suite) if default_suite
202
201
 
203
- next unless (suites[ste]['default_run'] == true)
202
+ suite_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
203
+ ordered_suites.each do |ste|
204
+ next unless suites[ste]['default_run'] == true
204
205
 
205
- name = suites[ste]['name']
206
+ name = suites[ste]['name']
206
207
 
207
- $stdout.puts("\n\n=== Suite '#{name}' Starting ===\n\n")
208
+ $stdout.puts("\n\n=== Suite '#{name}' Starting ===\n\n")
208
209
 
209
- nodesets = Array.new
210
- nodeset_path = File.join(suites[ste]['path'],'nodesets')
210
+ nodesets = []
211
+ nodeset_path = File.join(suites[ste]['path'], 'nodesets')
211
212
 
212
- if nodeset
213
- if nodeset == 'ALL'
214
- nodesets = Dir.glob(File.join(nodeset_path, '*.yml'))
213
+ if nodeset
214
+ if nodeset == 'ALL'
215
+ nodesets = Dir.glob(File.join(nodeset_path, '*.yml'))
215
216
 
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
217
+ # Make sure we run the default set first
218
+ default_set = nodesets.delete(File.join(nodeset_path, 'default.yml'))
219
+ nodesets.unshift(default_set) if default_set
224
220
  else
225
- nodesets << File.join(nodeset_path, 'default.yml')
221
+ nodeset.split(':').each do |tgt_nodeset|
222
+ nodesets << File.join(nodeset_path, "#{tgt_nodeset.strip}.yml")
223
+ end
226
224
  end
225
+ else
226
+ nodesets << File.join(nodeset_path, 'default.yml')
227
+ end
227
228
 
228
- refined_nodesets = []
229
-
230
- nodesets.each do |nodeset_yml|
231
- parsed_nodeset = ::Beaker::Options::HostsFileParser.parse_hosts_file(nodeset_yml)
229
+ refined_nodesets = []
232
230
 
233
- # Default to multi-node testing for backwards compatibility
234
- multi_node = (parsed_nodeset[:multi_node] == false ? false: true)
231
+ nodesets.each do |nodeset_yml|
232
+ parsed_nodeset = ::Beaker::Options::HostsFileParser.parse_hosts_file(nodeset_yml)
235
233
 
236
- if multi_node
237
- refined_nodesets.push(nodeset_yml)
238
- else
239
- parsed_nodeset_hosts = parsed_nodeset.delete(:HOSTS)
234
+ # Default to multi-node testing for backwards compatibility
235
+ multi_node = ((parsed_nodeset[:multi_node] == false) ? false : true)
240
236
 
241
- parsed_nodeset_hosts.each do |k,v|
237
+ if multi_node
238
+ refined_nodesets.push(nodeset_yml)
239
+ else
240
+ parsed_nodeset_hosts = parsed_nodeset.delete(:HOSTS)
242
241
 
243
- v[:roles] ||= []
244
- v[:roles] |= ['default']
242
+ parsed_nodeset_hosts.each do |k, v|
243
+ v[:roles] ||= []
244
+ v[:roles] |= ['default']
245
245
 
246
- tmp_nodeset = {
247
- :HOSTS => { k => v },
248
- :CONFIG => parsed_nodeset
249
- }
246
+ tmp_nodeset = {
247
+ HOSTS: { k => v },
248
+ CONFIG: parsed_nodeset
249
+ }
250
250
 
251
- tmp_nodeset_file = Tempfile.new("nodeset_#{k}-")
252
- tmp_nodeset_file.write(tmp_nodeset.to_yaml)
253
- tmp_nodeset_file.close
251
+ tmp_nodeset_file = Tempfile.new("nodeset_#{k}-")
252
+ tmp_nodeset_file.write(tmp_nodeset.to_yaml)
253
+ tmp_nodeset_file.close
254
254
 
255
- refined_nodesets.push(tmp_nodeset_file.path)
255
+ refined_nodesets.push(tmp_nodeset_file.path)
256
256
 
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
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
262
261
  end
263
262
  end
264
263
  end
265
264
  end
265
+ end
266
266
 
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
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
+ raise("*** Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found ***") if suite_config['fail_fast']
278
272
 
279
- ENV['BEAKER_setfile'] = nodeset_yml
273
+ $stdout.puts("=== Suite #{name} Nodeset '#{File.basename(nodeset_yml, '.yml')}' Not Found, Skipping ===")
274
+ next
280
275
 
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
276
+ end
277
+
278
+ ENV['BEAKER_setfile'] = nodeset_yml
286
279
 
287
- current_suite_task = Rake::Task[:beaker]
280
+ Rake::Task[:beaker].clear
281
+ RSpec::Core::RakeTask.new(:beaker) do |tsk|
282
+ tsk.rspec_opts = ['--color']
283
+ tsk.pattern = File.join(suites[ste]['path'])
284
+ end
288
285
 
289
- if suite_config['fail_fast'] == true
286
+ current_suite_task = Rake::Task[:beaker]
287
+
288
+ if suite_config['fail_fast'] == true
289
+ current_suite_task.execute
290
+ else
291
+ begin
290
292
  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
293
+ rescue SystemExit
294
+ failures[suites[ste]['name']] = {
295
+ 'path' => suites[ste]['path'],
296
+ 'nodeset' => File.basename(nodeset_yml, '.yml')
297
+ }
300
298
  end
301
-
302
- $stdout.puts("\n\n=== Suite '#{name}' Complete ===\n\n")
303
299
  end
300
+
301
+ $stdout.puts("\n\n=== Suite '#{name}' Complete ===\n\n")
304
302
  end
305
- suite_end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
303
+ end
304
+ suite_end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
306
305
 
307
- suite_run_time = ((suite_end_time - suite_start_time)/60).round(2)
306
+ suite_run_time = ((suite_end_time - suite_start_time) / 60).round(2)
308
307
 
309
- $stdout.puts("== Total Runtime: #{suite_run_time} minutes ==\n\n")
308
+ $stdout.puts("== Total Runtime: #{suite_run_time} minutes ==\n\n")
310
309
 
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
310
+ unless failures.keys.empty?
311
+ $stdout.puts('The following tests had failures:')
312
+ failures.keys.sort.each do |ste|
313
+ $stdout.puts(" * #{ste} => #{failures[ste]['path']} on #{failures[ste]['nodeset']}")
316
314
  end
317
315
  end
318
316
  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