beaker 4.38.1 → 4.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +72 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +9 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -59
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
@@ -8,18 +8,18 @@ end
8
8
  describe ClassMixedWithDSLStructure do
9
9
  include Beaker::DSL::Assertions
10
10
 
11
- let (:logger) { double }
12
- let (:metadata) { @metadata ||= {} }
11
+ let(:logger) { double }
12
+ let(:metadata) { @metadata ||= {} }
13
13
 
14
- before :each do
14
+ before do
15
15
  allow( subject ).to receive(:metadata).and_return(metadata)
16
16
  end
17
17
 
18
18
  describe '#tag' do
19
- let ( :test_tag_and ) { @test_tag_and || [] }
20
- let ( :test_tag_or ) { @test_tag_or || [] }
21
- let ( :test_tag_exclude ) { @test_tag_exclude || [] }
22
- let ( :options ) {
19
+ let( :test_tag_and ) { @test_tag_and || [] }
20
+ let( :test_tag_or ) { @test_tag_or || [] }
21
+ let( :test_tag_exclude ) { @test_tag_exclude || [] }
22
+ let( :options ) {
23
23
  opts = Beaker::Options::OptionsHash.new
24
24
  opts[:test_tag_and] = test_tag_and
25
25
  opts[:test_tag_or] = test_tag_or
@@ -27,7 +27,7 @@ describe ClassMixedWithDSLStructure do
27
27
  opts
28
28
  }
29
29
 
30
- before :each do
30
+ before do
31
31
  allow( subject ).to receive( :platform_specific_tag_confines )
32
32
  end
33
33
 
@@ -62,7 +62,7 @@ describe ClassMixedWithDSLStructure do
62
62
  subject.instance_variable_set(:@options, options)
63
63
 
64
64
  allow( subject ).to receive( :path )
65
- expect( subject ).to receive( :skip_test ).never
65
+ expect( subject ).not_to receive( :skip_test )
66
66
  subject.tag(*test_tags)
67
67
  end
68
68
 
@@ -93,7 +93,7 @@ describe ClassMixedWithDSLStructure do
93
93
  subject.instance_variable_set(:@options, options)
94
94
 
95
95
  allow( subject ).to receive( :path )
96
- expect( subject ).to receive( :skip_test ).never
96
+ expect( subject ).not_to receive( :skip_test )
97
97
  subject.tag(*test_tags)
98
98
  end
99
99
 
@@ -113,7 +113,7 @@ describe ClassMixedWithDSLStructure do
113
113
  subject.instance_variable_set(:@options, options)
114
114
 
115
115
  allow( subject ).to receive( :path )
116
- expect( subject ).to receive( :skip_test ).never
116
+ expect( subject ).not_to receive( :skip_test )
117
117
  subject.tag(*test_tags)
118
118
  end
119
119
 
@@ -131,9 +131,9 @@ describe ClassMixedWithDSLStructure do
131
131
  end
132
132
 
133
133
  describe Beaker::DSL::TestTagging::PlatformTagConfiner do
134
- let ( :confines_array ) { @confines_array || [] }
135
- let ( :confiner ) {
136
- Beaker::DSL::TestTagging::PlatformTagConfiner.new( confines_array )
134
+ let( :confines_array ) { @confines_array || [] }
135
+ let( :confiner ) {
136
+ described_class.new( confines_array )
137
137
  }
138
138
 
139
139
  describe '#initialize' do
@@ -240,7 +240,7 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
240
240
  key_combos_to_test << [ 'tag2', 'tag3', 'tag4' ]
241
241
  key_combos_to_test << fake_confine_details_hash.keys()
242
242
 
243
- before :each do
243
+ before do
244
244
  confiner.instance_variable_set(
245
245
  :@tag_confine_details_hash, fake_confine_details_hash
246
246
  )
@@ -262,7 +262,7 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
262
262
 
263
263
  details = confiner.confine_details( key_combo_to_have )
264
264
  have_nots.each do |confine_details|
265
- expect( details ).to_not include( confine_details )
265
+ expect( details ).not_to include( confine_details )
266
266
  end
267
267
  haves.each do |confine_details|
268
268
  expect( details ).to include( confine_details )
@@ -13,21 +13,21 @@ describe ClassMixedWithDSLWrappers do
13
13
  end
14
14
 
15
15
  describe '#powershell' do
16
- it 'should pass "powershell.exe <args> -Command <command>" to Command' do
16
+ it 'passes "powershell.exe <args> -Command <command>" to Command' do
17
17
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'")
18
18
  expect(command.command ).to be === 'powershell.exe'
19
19
  expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
20
20
  expect( command.options ).to be === {}
21
21
  end
22
22
 
23
- it 'should merge the arguments provided with the defaults' do
23
+ it 'merges the arguments provided with the defaults' do
24
24
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'ExecutionPolicy' => 'Unrestricted'})
25
25
  expect( command.command).to be === 'powershell.exe'
26
26
  expect( command.args ).to be === ["-ExecutionPolicy Unrestricted", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
27
27
  expect( command.options ).to be === {}
28
28
  end
29
29
 
30
- it 'should use EncodedCommand when EncodedCommand => true' do
30
+ it 'uses EncodedCommand when EncodedCommand => true' do
31
31
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
32
32
  cmd = subject.encode_command(cmd)
33
33
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => true})
@@ -36,7 +36,7 @@ describe ClassMixedWithDSLWrappers do
36
36
  expect( command.options ).to be === {}
37
37
  end
38
38
 
39
- it 'should use EncodedCommand when EncodedCommand => ""' do
39
+ it 'uses EncodedCommand when EncodedCommand => ""' do
40
40
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
41
41
  cmd = subject.encode_command(cmd)
42
42
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => ""})
@@ -45,7 +45,7 @@ describe ClassMixedWithDSLWrappers do
45
45
  expect( command.options ).to be === {}
46
46
  end
47
47
 
48
- it 'should use EncodedCommand when EncodedCommand => nil' do
48
+ it 'uses EncodedCommand when EncodedCommand => nil' do
49
49
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
50
50
  cmd = subject.encode_command(cmd)
51
51
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => nil})
@@ -54,14 +54,14 @@ describe ClassMixedWithDSLWrappers do
54
54
  expect( command.options ).to be === {}
55
55
  end
56
56
 
57
- it 'should not use EncodedCommand when EncodedCommand => false' do
57
+ it 'does not use EncodedCommand when EncodedCommand => false' do
58
58
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => false})
59
59
  expect(command.command ).to be === 'powershell.exe'
60
60
  expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
61
61
  expect( command.options ).to be === {}
62
62
  end
63
63
 
64
- it 'should not use EncodedCommand when EncodedCommand not present' do
64
+ it 'does not use EncodedCommand when EncodedCommand not present' do
65
65
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {})
66
66
  expect(command.command ).to be === 'powershell.exe'
67
67
  expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
@@ -18,7 +18,7 @@ module Cisco
18
18
 
19
19
  context 'for cisco_nexus-7' do
20
20
 
21
- before :each do
21
+ before do
22
22
  @platform = 'cisco_nexus-7-x86_64'
23
23
  end
24
24
 
@@ -71,7 +71,7 @@ module Cisco
71
71
 
72
72
  context 'for cisco_ios_xr-6' do
73
73
 
74
- before :each do
74
+ before do
75
75
  @platform = 'cisco_ios_xr-6-x86_64'
76
76
  end
77
77
 
@@ -111,7 +111,7 @@ module Cisco
111
111
 
112
112
  context 'for cisco_nexus-7' do
113
113
 
114
- before :each do
114
+ before do
115
115
  @platform = 'cisco_nexus-7-x86_64'
116
116
  @options = { :user => 'non_root' }
117
117
  end
@@ -150,7 +150,7 @@ module Cisco
150
150
 
151
151
  context 'for cisco_ios_xr-6' do
152
152
 
153
- before :each do
153
+ before do
154
154
  @platform = 'cisco_ios_xr-6-x86_64'
155
155
  @options = { :user => 'non_root' }
156
156
  end
@@ -192,7 +192,7 @@ module Cisco
192
192
 
193
193
  context 'for cisco_nexus-7' do
194
194
 
195
- before :each do
195
+ before do
196
196
  @platform = 'cisco_nexus-7-x86_64'
197
197
  end
198
198
 
@@ -220,7 +220,7 @@ module Cisco
220
220
  end
221
221
 
222
222
  context 'for cisco_ios_xr-6' do
223
- before :each do
223
+ before do
224
224
  @platform = 'cisco_ios_xr-6-x86_64'
225
225
  end
226
226
 
@@ -275,7 +275,7 @@ module Cisco
275
275
  describe '#validate_setup' do
276
276
 
277
277
  context 'on the cisco_nexus-7 platform' do
278
- before :each do
278
+ before do
279
279
  @platform = 'cisco_nexus-7-x86_64'
280
280
  end
281
281
 
@@ -306,7 +306,7 @@ module Cisco
306
306
  end
307
307
 
308
308
  context 'on the cisco_ios_xr-6 platform' do
309
- before :each do
309
+ before do
310
310
  @platform = 'cisco_ios_xr-6-x86_64'
311
311
  end
312
312
 
@@ -19,9 +19,9 @@ module Beaker
19
19
  end
20
20
  end
21
21
 
22
- let (:opts) { @opts || {} }
23
- let (:logger) { double( 'logger' ).as_null_object }
24
- let (:instance) { FreeBSDExecTest.new(opts, logger) }
22
+ let(:opts) { @opts || {} }
23
+ let(:logger) { double( 'logger' ).as_null_object }
24
+ let(:instance) { FreeBSDExecTest.new(opts, logger) }
25
25
 
26
26
  context "echo_to_file" do
27
27
 
@@ -24,9 +24,9 @@ module Beaker
24
24
 
25
25
  end
26
26
 
27
- let (:opts) { @opts || {} }
28
- let (:logger) { double( 'logger' ).as_null_object }
29
- let (:instance) { FreeBSDPkgTest.new(opts, logger) }
27
+ let(:opts) { @opts || {} }
28
+ let(:logger) { double( 'logger' ).as_null_object }
29
+ let(:instance) { FreeBSDPkgTest.new(opts, logger) }
30
30
  let(:cond) do
31
31
  'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
32
32
  end
@@ -48,6 +48,7 @@ module Beaker
48
48
  expect( instance ).to receive(:exec).with('',{:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
49
49
  expect( instance.pkgng_active? ).to be true
50
50
  end
51
+
51
52
  it "returns false if pkgng is unavailable" do
52
53
  expect( instance ).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
53
54
  expect( Beaker::Command ).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
@@ -65,6 +66,7 @@ module Beaker
65
66
  instance.install_package('rsync')
66
67
  end
67
68
  end
69
+
68
70
  context "with pkgng" do
69
71
  it "runs the correct install command" do
70
72
  expect( instance ).to receive(:pkgng_active?).once.and_return(true)
@@ -84,6 +86,7 @@ module Beaker
84
86
  instance.check_for_package('rsync')
85
87
  end
86
88
  end
89
+
87
90
  context "with pkgng" do
88
91
  it "runs the correct checking command" do
89
92
  expect( instance ).to receive(:pkgng_active?).once.and_return(true)
@@ -20,9 +20,9 @@ module Beaker
20
20
 
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { MacExecTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { MacExecTest.new(opts, logger) }
26
26
 
27
27
  describe '#selinux_enabled?' do
28
28
  it 'does not call selinuxenabled' do
@@ -26,28 +26,28 @@ module Mac
26
26
  end
27
27
 
28
28
  it 'returns two strings that include the passed parameters' do
29
- allow( host ).to receive( :link_exists? ) { true }
29
+ allow( host ).to receive( :link_exists? ).and_return(true)
30
30
  return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1', :download_url => '' )
31
31
  expect( return1 ).to match( /pc1/ )
32
32
  expect( return2 ).to match( /pav1/ )
33
33
  end
34
34
 
35
35
  it 'gets the correct file type' do
36
- allow( host ).to receive( :link_exists? ) { true }
36
+ allow( host ).to receive( :link_exists? ).and_return(true)
37
37
  _, return2 = host.puppet_agent_dev_package_info( 'pc2', 'pav2', :download_url => '' )
38
38
  expect( return2 ).to match( /\.dmg$/ )
39
39
  end
40
40
 
41
41
  it 'adds the version dot correctly if not supplied' do
42
42
  @platform = 'osx-10.12-x86_64'
43
- allow( host ).to receive( :link_exists? ) { true }
43
+ allow( host ).to receive( :link_exists? ).and_return(true)
44
44
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3', :download_url => '' )
45
45
  expect( release_path_end ).to match( /10\.12/ )
46
46
  expect( release_file ).to match( /10\.12/ )
47
47
  end
48
48
 
49
49
  it 'runs the correct install for osx platforms (newest link format)' do
50
- allow( host ).to receive( :link_exists? ) { true }
50
+ allow( host ).to receive( :link_exists? ).and_return(true)
51
51
 
52
52
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4', :download_url => '' )
53
53
  # verify the mac package name starts the name correctly
@@ -71,7 +71,7 @@ module Mac
71
71
  end
72
72
 
73
73
  it 'runs the correct install for osx platforms (old link format)' do
74
- allow( host ).to receive( :link_exists? ) { false }
74
+ allow( host ).to receive( :link_exists? ).and_return(false)
75
75
 
76
76
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8', :download_url => '' )
77
77
  # verify the mac package name starts the name correctly
@@ -84,7 +84,7 @@ module Mac
84
84
  end
85
85
 
86
86
  describe '#pe_puppet_agent_promoted_package_info' do
87
- before :each do
87
+ before do
88
88
  @platform = "osx-10.15-x86_64"
89
89
  end
90
90
 
@@ -20,9 +20,9 @@ module Beaker
20
20
 
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { PSWindowsExecTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { PSWindowsExecTest.new(opts, logger) }
26
26
 
27
27
  context "rm" do
28
28
 
@@ -40,12 +40,12 @@ module Beaker
40
40
 
41
41
  it 'rm first' do
42
42
  expect(instance).to receive(:execute).with("del /s /q \"\\destination\\path\\of\\content\"").and_return(0)
43
- expect(instance).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
43
+ expect(instance).to receive(:execute).with("move /y #{origin.tr('/', '\\')} #{destination.tr('/', '\\')}").and_return(0)
44
44
  expect(instance.mv(origin, destination)).to eq(0)
45
45
  end
46
46
 
47
47
  it 'does not rm' do
48
- expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
48
+ expect( instance ).to receive(:execute).with("move /y #{origin.tr('/', '\\')} #{destination.tr('/', '\\')}").and_return(0)
49
49
  expect( instance.mv(origin, destination, false) ).to be === 0
50
50
  end
51
51
  end
@@ -57,6 +57,7 @@ module Beaker
57
57
 
58
58
  context 'file exists' do
59
59
  let(:stdout) { 'True' }
60
+
60
61
  it 'sets the modified_at date' do
61
62
  file = 'C:\path\to\file'
62
63
  expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
@@ -69,6 +70,7 @@ module Beaker
69
70
 
70
71
  context 'file does not exist' do
71
72
  let(:stdout) { 'False' }
73
+
72
74
  it 'creates it and sets the modified_at date' do
73
75
  file = 'C:\path\to\file'
74
76
  expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
@@ -104,6 +106,7 @@ module Beaker
104
106
  allow(instance).to receive(:execute)
105
107
  .with(where_command, :accept_all_exit_codes => true).and_return(result)
106
108
  end
109
+
107
110
  let(:where_command) { "cmd /C \"where ruby\"" }
108
111
 
109
112
  context 'when only the environment variable PATH is used' do
@@ -20,13 +20,14 @@ module Beaker
20
20
  end
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { PSWindowsFileTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { PSWindowsFileTest.new(opts, logger) }
26
26
 
27
27
  describe '#cat' do
28
28
  let(:path) { '/path/to/cat' }
29
29
  let(:content) { 'file content' }
30
+
30
31
  it 'reads output for file' do
31
32
  expect(instance).to receive(:exec).and_return(double(stdout: content))
32
33
  expect(Beaker::Command).to receive(:new).with('powershell.exe', array_including("-Command type #{path}"))
@@ -36,6 +37,7 @@ module Beaker
36
37
 
37
38
  describe '#file_exist?' do
38
39
  let(:path) { '/path/to/test/file.txt' }
40
+
39
41
  context 'file exists' do
40
42
  it 'returns true' do
41
43
  expect(instance).to receive(:exec).and_return(double(stdout: "true\n"))
@@ -63,6 +65,7 @@ module Beaker
63
65
 
64
66
  context 'with dirname sent' do
65
67
  let(:name) { 'my_dir' }
68
+
66
69
  it 'returns the path to my_dir' do
67
70
  expect(Beaker::Command).to receive(:new).
68
71
  with('powershell.exe', array_including('-Command [System.IO.Path]::GetTempPath()')).
@@ -12,7 +12,7 @@ module PSWindows
12
12
  }
13
13
  let(:host) {
14
14
  opts = options.merge(platform)
15
- opts.merge!({ :is_cygwin => false })
15
+ opts[:is_cygwin] = false
16
16
  make_host( 'name', opts )
17
17
  }
18
18
 
@@ -21,9 +21,9 @@ module Beaker
21
21
 
22
22
  end
23
23
 
24
- let (:opts) { @opts || {} }
25
- let (:logger) { double( 'logger' ).as_null_object }
26
- let (:instance) { UnixExecTest.new(opts, logger) }
24
+ let(:opts) { @opts || {} }
25
+ let(:logger) { double( 'logger' ).as_null_object }
26
+ let(:instance) { UnixExecTest.new(opts, logger) }
27
27
 
28
28
  context "rm" do
29
29
 
@@ -65,7 +65,7 @@ module Beaker
65
65
  let(:host) { {'pathseparator' => ':'} }
66
66
 
67
67
  it 'returns a blank string if theres no env' do
68
- expect( instance ).to receive( :is_powershell? ).never
68
+ expect( instance ).not_to receive( :is_powershell? )
69
69
  expect( instance.environment_string( {} ) ).to be == ''
70
70
  end
71
71
 
@@ -82,9 +82,9 @@ module Beaker
82
82
 
83
83
  describe '#ssh_permit_user_environment' do
84
84
  context 'When called without error' do
85
- let (:directory) {'/directory'}
86
- let (:ssh_command) {"echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"}
87
- let (:ssh_move) {"mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"}
85
+ let(:directory) {'/directory'}
86
+ let(:ssh_command) {"echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"}
87
+ let(:ssh_move) {"mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"}
88
88
 
89
89
  platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS
90
90
 
@@ -96,7 +96,7 @@ module Beaker
96
96
  expect(Beaker::Command).to receive(:new).with(ssh_move)
97
97
  expect(Beaker::Command).to receive(:new).with(ssh_command)
98
98
  expect(instance).to receive(:ssh_service_restart)
99
- expect{instance.ssh_permit_user_environment}.to_not raise_error
99
+ expect{instance.ssh_permit_user_environment}.not_to raise_error
100
100
  end
101
101
  end
102
102
  end
@@ -115,7 +115,7 @@ module Beaker
115
115
  opts['platform'] = platform
116
116
  expect(instance).to receive(:exec)
117
117
  expect(Beaker::Command).to receive(:new).with("systemctl restart sshd.service")
118
- expect{instance.ssh_service_restart}.to_not raise_error
118
+ expect{instance.ssh_service_restart}.not_to raise_error
119
119
  end
120
120
  end
121
121
 
@@ -124,7 +124,7 @@ module Beaker
124
124
  opts['platform'] = platform
125
125
  expect(instance).to receive(:exec)
126
126
  expect(Beaker::Command).to receive(:new).with("service ssh restart")
127
- expect{instance.ssh_service_restart}.to_not raise_error
127
+ expect{instance.ssh_service_restart}.not_to raise_error
128
128
  end
129
129
  end
130
130
 
@@ -133,7 +133,7 @@ module Beaker
133
133
  opts['platform'] = "#{platform}-arch"
134
134
  expect(instance).to receive(:exec)
135
135
  expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart")
136
- expect{instance.ssh_service_restart}.to_not raise_error
136
+ expect{instance.ssh_service_restart}.not_to raise_error
137
137
  end
138
138
  end
139
139
 
@@ -230,13 +230,13 @@ module Beaker
230
230
  }
231
231
 
232
232
  # no-op response
233
- let (:response) { double( 'response' ) }
234
- let (:boot_time_initial_response) { double( 'response' ) }
233
+ let(:response) { double( 'response' ) }
234
+ let(:boot_time_initial_response) { double( 'response' ) }
235
235
 
236
- let (:boot_time_success_response) { double( 'response' ) }
237
- let (:sleep_time) { 10 }
236
+ let(:boot_time_success_response) { double( 'response' ) }
237
+ let(:sleep_time) { 10 }
238
238
 
239
- before :each do
239
+ before do
240
240
  # stubs enough to survive the first boot_time call & output parsing
241
241
  # note: just stubs input-chain between calls, parsing methods still run
242
242
  allow(Beaker::Command).to receive(:new).with('last -F reboot || who -b').and_return(:boot_time_command_stub)
@@ -253,8 +253,8 @@ module Beaker
253
253
  check_cmd_output.each do |check_os, cmd_opts|
254
254
  cmd_opts.each do |cmd_name, cmd_outputs|
255
255
  context "on '#{check_os}' with the '#{cmd_name}' command" do
256
- let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
257
- let (:boot_time_success_stdout) { cmd_outputs[:success] }
256
+ let(:boot_time_initial_stdout) { cmd_outputs[:initial] }
257
+ let(:boot_time_success_stdout) { cmd_outputs[:success] }
258
258
 
259
259
  it 'passes with defaults' do
260
260
  expect(instance).to receive(:sleep).with(sleep_time)
@@ -290,7 +290,7 @@ module Beaker
290
290
  end
291
291
 
292
292
  context 'command errors' do
293
- before :each do
293
+ before do
294
294
  allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
295
295
  end
296
296
 
@@ -310,7 +310,7 @@ module Beaker
310
310
 
311
311
  context 'incorrect time string' do
312
312
  context 'original time' do
313
- let (:boot_time_initial_stdout) { 'boot bad' }
313
+ let(:boot_time_initial_stdout) { 'boot bad' }
314
314
 
315
315
  it 'raises a reboot failure' do
316
316
  # Handle the 'retry'
@@ -323,7 +323,7 @@ module Beaker
323
323
  end
324
324
 
325
325
  context 'current time' do
326
- let (:boot_time_success_stdout) { 'boot bad' }
326
+ let(:boot_time_success_stdout) { 'boot bad' }
327
327
 
328
328
  it 'raises a reboot failure' do
329
329
  expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
@@ -345,8 +345,8 @@ module Beaker
345
345
  check_cmd_output.each do |check_os, cmd_opts|
346
346
  cmd_opts.each do |cmd_name, cmd_outputs|
347
347
  context "on '#{check_os}' with the '#{cmd_name}' command" do
348
- let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
349
- let (:boot_time_success_stdout) { cmd_outputs[:initial] }
348
+ let(:boot_time_initial_stdout) { cmd_outputs[:initial] }
349
+ let(:boot_time_success_stdout) { cmd_outputs[:initial] }
350
350
 
351
351
  it 'raises RebootFailure' do
352
352
  expect(instance).to receive(:sleep).with(sleep_time)
@@ -366,7 +366,7 @@ module Beaker
366
366
  expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
367
367
  expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
368
368
 
369
- expect { instance.reboot(wait_time=sleep_time, max_connection_tries=9, boot_time_retries=10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
369
+ expect { instance.reboot(sleep_time, 9, 10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
370
370
  end
371
371
  end
372
372
  end