beaker 4.38.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +36 -11
  5. data/.rubocop.yml +75 -0
  6. data/.rubocop_todo.yml +239 -0
  7. data/CHANGELOG.md +88 -33
  8. data/Gemfile +16 -4
  9. data/HISTORY.md +103 -0
  10. data/Rakefile +101 -112
  11. data/acceptance/config/acceptance-options.rb +1 -1
  12. data/acceptance/config/base/acceptance-options.rb +2 -2
  13. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  14. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  15. data/acceptance/fixtures/module/Gemfile +1 -1
  16. data/acceptance/fixtures/module/Rakefile +3 -3
  17. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
  18. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
  19. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  20. data/acceptance/lib/helpers/test_helper.rb +7 -6
  21. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  22. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  24. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +7 -8
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +9 -7
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +23 -30
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +21 -16
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
  41. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
  42. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  43. data/acceptance/tests/base/dsl/structure_test.rb +9 -21
  44. data/acceptance/tests/base/host/file_test.rb +8 -8
  45. data/acceptance/tests/base/host/group_test.rb +2 -3
  46. data/acceptance/tests/base/host/host_test.rb +69 -66
  47. data/acceptance/tests/base/host/packages.rb +27 -30
  48. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  49. data/acceptance/tests/base/host/user_test.rb +2 -3
  50. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  51. data/acceptance/tests/base/test_suite/export.rb +6 -9
  52. data/acceptance/tests/install/from_file.rb +3 -5
  53. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  54. data/acceptance/tests/subcommands/destroy.rb +19 -21
  55. data/acceptance/tests/subcommands/exec.rb +0 -1
  56. data/acceptance/tests/subcommands/init.rb +2 -3
  57. data/acceptance/tests/subcommands/provision.rb +0 -1
  58. data/beaker.gemspec +10 -14
  59. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  60. data/docs/concepts/style_guide.md +1 -1
  61. data/docs/how_to/debug_beaker_tests.md +13 -13
  62. data/docs/how_to/hosts/eos.md +2 -12
  63. data/docs/how_to/install_puppet.md +0 -18
  64. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  65. data/docs/how_to/the_beaker_dsl.md +0 -2
  66. data/lib/beaker/cli.rb +63 -74
  67. data/lib/beaker/command.rb +22 -30
  68. data/lib/beaker/command_factory.rb +4 -3
  69. data/lib/beaker/dsl/assertions.rb +7 -19
  70. data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
  71. data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
  72. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  73. data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
  74. data/lib/beaker/dsl/helpers.rb +2 -4
  75. data/lib/beaker/dsl/outcomes.rb +17 -19
  76. data/lib/beaker/dsl/patterns.rb +1 -3
  77. data/lib/beaker/dsl/roles.rb +18 -21
  78. data/lib/beaker/dsl/structure.rb +55 -67
  79. data/lib/beaker/dsl/test_tagging.rb +7 -10
  80. data/lib/beaker/dsl/wrappers.rb +15 -16
  81. data/lib/beaker/dsl.rb +2 -3
  82. data/lib/beaker/host/aix/exec.rb +1 -1
  83. data/lib/beaker/host/aix/file.rb +0 -1
  84. data/lib/beaker/host/aix/group.rb +3 -3
  85. data/lib/beaker/host/aix/user.rb +3 -3
  86. data/lib/beaker/host/aix.rb +3 -4
  87. data/lib/beaker/host/cisco.rb +36 -48
  88. data/lib/beaker/host/eos.rb +4 -30
  89. data/lib/beaker/host/freebsd/exec.rb +1 -1
  90. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  91. data/lib/beaker/host/freebsd.rb +9 -12
  92. data/lib/beaker/host/mac/exec.rb +5 -5
  93. data/lib/beaker/host/mac/group.rb +13 -13
  94. data/lib/beaker/host/mac/pkg.rb +6 -109
  95. data/lib/beaker/host/mac/user.rb +7 -7
  96. data/lib/beaker/host/mac.rb +8 -9
  97. data/lib/beaker/host/pswindows/exec.rb +70 -74
  98. data/lib/beaker/host/pswindows/file.rb +4 -6
  99. data/lib/beaker/host/pswindows/group.rb +5 -5
  100. data/lib/beaker/host/pswindows/pkg.rb +17 -17
  101. data/lib/beaker/host/pswindows/user.rb +4 -4
  102. data/lib/beaker/host/pswindows.rb +4 -3
  103. data/lib/beaker/host/unix/exec.rb +86 -88
  104. data/lib/beaker/host/unix/file.rb +41 -47
  105. data/lib/beaker/host/unix/group.rb +3 -3
  106. data/lib/beaker/host/unix/pkg.rb +158 -421
  107. data/lib/beaker/host/unix/user.rb +4 -4
  108. data/lib/beaker/host/unix.rb +18 -20
  109. data/lib/beaker/host/windows/exec.rb +20 -20
  110. data/lib/beaker/host/windows/file.rb +5 -5
  111. data/lib/beaker/host/windows/group.rb +5 -5
  112. data/lib/beaker/host/windows/pkg.rb +6 -57
  113. data/lib/beaker/host/windows/user.rb +4 -4
  114. data/lib/beaker/host/windows.rb +13 -13
  115. data/lib/beaker/host.rb +82 -139
  116. data/lib/beaker/host_prebuilt_steps.rb +121 -233
  117. data/lib/beaker/hypervisor/noop.rb +2 -4
  118. data/lib/beaker/hypervisor.rb +46 -63
  119. data/lib/beaker/local_connection.rb +4 -6
  120. data/lib/beaker/logger.rb +71 -85
  121. data/lib/beaker/logger_junit.rb +22 -26
  122. data/lib/beaker/network_manager.rb +40 -43
  123. data/lib/beaker/options/command_line_parser.rb +12 -23
  124. data/lib/beaker/options/hosts_file_parser.rb +34 -25
  125. data/lib/beaker/options/options_file_parser.rb +3 -6
  126. data/lib/beaker/options/options_hash.rb +3 -10
  127. data/lib/beaker/options/parser.rb +89 -105
  128. data/lib/beaker/options/presets.rb +114 -123
  129. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  130. data/lib/beaker/options/validator.rb +26 -31
  131. data/lib/beaker/perf.rb +29 -34
  132. data/lib/beaker/platform.rb +38 -46
  133. data/lib/beaker/result.rb +7 -6
  134. data/lib/beaker/shared/error_handler.rb +8 -10
  135. data/lib/beaker/shared/fog_credentials.rb +5 -9
  136. data/lib/beaker/shared/host_manager.rb +40 -46
  137. data/lib/beaker/shared/options_resolver.rb +3 -7
  138. data/lib/beaker/shared/repetition.rb +6 -8
  139. data/lib/beaker/shared/semvar.rb +39 -43
  140. data/lib/beaker/shared/timed.rb +2 -5
  141. data/lib/beaker/shared.rb +1 -1
  142. data/lib/beaker/ssh_connection.rb +46 -55
  143. data/lib/beaker/subcommand.rb +23 -30
  144. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  145. data/lib/beaker/tasks/quick_start.rb +5 -10
  146. data/lib/beaker/tasks/rake_task.rb +26 -28
  147. data/lib/beaker/tasks/test.rb +4 -4
  148. data/lib/beaker/test_case.rb +15 -27
  149. data/lib/beaker/test_suite.rb +35 -39
  150. data/lib/beaker/test_suite_result.rb +52 -57
  151. data/lib/beaker/version.rb +1 -1
  152. data/lib/beaker.rb +5 -6
  153. data/spec/beaker/cli_spec.rb +135 -153
  154. data/spec/beaker/command_spec.rb +64 -58
  155. data/spec/beaker/dsl/assertions_spec.rb +38 -47
  156. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
  157. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  158. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
  159. data/spec/beaker/dsl/outcomes_spec.rb +15 -14
  160. data/spec/beaker/dsl/roles_spec.rb +170 -132
  161. data/spec/beaker/dsl/structure_spec.rb +181 -163
  162. data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
  163. data/spec/beaker/dsl/wrappers_spec.rb +39 -40
  164. data/spec/beaker/host/aix_spec.rb +14 -14
  165. data/spec/beaker/host/cisco_spec.rb +92 -102
  166. data/spec/beaker/host/eos_spec.rb +15 -36
  167. data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
  168. data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
  169. data/spec/beaker/host/mac/exec_spec.rb +4 -5
  170. data/spec/beaker/host/mac/group_spec.rb +47 -56
  171. data/spec/beaker/host/mac/user_spec.rb +53 -62
  172. data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
  173. data/spec/beaker/host/pswindows/file_spec.rb +21 -18
  174. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  175. data/spec/beaker/host/pswindows_spec.rb +14 -14
  176. data/spec/beaker/host/unix/exec_spec.rb +87 -92
  177. data/spec/beaker/host/unix/file_spec.rb +76 -82
  178. data/spec/beaker/host/unix/pkg_spec.rb +165 -407
  179. data/spec/beaker/host/unix_spec.rb +11 -207
  180. data/spec/beaker/host/windows/exec_spec.rb +32 -34
  181. data/spec/beaker/host/windows/file_spec.rb +22 -23
  182. data/spec/beaker/host/windows/group_spec.rb +17 -19
  183. data/spec/beaker/host/windows/pkg_spec.rb +10 -13
  184. data/spec/beaker/host/windows/user_spec.rb +17 -23
  185. data/spec/beaker/host/windows_spec.rb +39 -39
  186. data/spec/beaker/host_prebuilt_steps_spec.rb +193 -341
  187. data/spec/beaker/host_spec.rb +241 -312
  188. data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
  189. data/spec/beaker/localhost_connection_spec.rb +14 -13
  190. data/spec/beaker/logger_junit_spec.rb +22 -34
  191. data/spec/beaker/logger_spec.rb +174 -155
  192. data/spec/beaker/network_manager_spec.rb +27 -27
  193. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  194. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  195. data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
  196. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  197. data/spec/beaker/options/options_hash_spec.rb +7 -9
  198. data/spec/beaker/options/parser_spec.rb +187 -187
  199. data/spec/beaker/options/presets_spec.rb +8 -10
  200. data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
  201. data/spec/beaker/options/validator_spec.rb +27 -28
  202. data/spec/beaker/perf_spec.rb +32 -34
  203. data/spec/beaker/platform_spec.rb +27 -37
  204. data/spec/beaker/shared/error_handler_spec.rb +8 -17
  205. data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
  206. data/spec/beaker/shared/host_manager_spec.rb +55 -89
  207. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  208. data/spec/beaker/shared/repetition_spec.rb +24 -31
  209. data/spec/beaker/shared/semvar_spec.rb +21 -26
  210. data/spec/beaker/ssh_connection_spec.rb +85 -90
  211. data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
  212. data/spec/beaker/subcommand_spec.rb +89 -89
  213. data/spec/beaker/test_case_spec.rb +33 -62
  214. data/spec/beaker/test_suite_spec.rb +153 -160
  215. data/spec/helpers.rb +48 -53
  216. data/spec/matchers.rb +9 -8
  217. data/spec/mocks.rb +6 -11
  218. data/spec/spec_helper.rb +0 -4
  219. metadata +60 -85
  220. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  221. data/acceptance/tests/base/external_resources_test.rb +0 -31
  222. data/spec/beaker/host/mac_spec.rb +0 -113
  223. data/spec/mock_fission.rb +0 -60
  224. data/spec/mock_vsphere.rb +0 -314
  225. data/spec/mock_vsphere_helper.rb +0 -183
@@ -4,24 +4,24 @@ module Beaker
4
4
  describe Host do
5
5
  let(:options) { @options ? @options : {} }
6
6
  let(:platform) { @platform ? { :platform => @platform } : {} }
7
- let(:host) { make_host( 'name', options.merge(platform) ) }
7
+ let(:host) { make_host('name', options.merge(platform)) }
8
8
 
9
9
  it 'creates a windows host given a windows config' do
10
10
  @platform = 'windows'
11
- expect( host ).to be_a_kind_of Windows::Host
11
+ expect(host).to be_a Windows::Host
12
12
  end
13
13
 
14
14
  it 'defaults to a unix host' do
15
- expect( host ).to be_a_kind_of Unix::Host
15
+ expect(host).to be_a Unix::Host
16
16
  end
17
17
 
18
18
  it 'can be read like a hash' do
19
- expect{ host['value'] }.to_not raise_error
19
+ expect { host['value'] }.not_to raise_error
20
20
  end
21
21
 
22
22
  it 'can be written like a hash' do
23
23
  host['value'] = 'blarg'
24
- expect( host['value'] ).to be === 'blarg'
24
+ expect(host['value']).to be === 'blarg'
25
25
  end
26
26
 
27
27
  describe "host types" do
@@ -29,39 +29,16 @@ module Beaker
29
29
 
30
30
  it "can be a pe host" do
31
31
  options['type'] = 'pe'
32
- expect(host.is_pe?).to be_truthy
33
- expect(host.use_service_scripts?).to be_truthy
34
- expect(host.is_using_passenger?).to be_truthy
35
- expect(host.graceful_restarts?).to be_falsy
32
+ expect(host).to be_is_pe
36
33
  end
37
34
 
38
35
  it "can be a foss-source host" do
39
- expect(host.is_pe?).to be_falsy
40
- expect(host.use_service_scripts?).to be_falsy
41
- expect(host.is_using_passenger?).to be_falsy
42
- end
43
-
44
- it "can be a foss-package host" do
45
- options['use-service'] = true
46
- expect(host.is_pe?).to be_falsy
47
- expect(host.use_service_scripts?).to be_truthy
48
- expect(host.is_using_passenger?).to be_falsy
49
- expect(host.graceful_restarts?).to be_falsy
50
- end
51
-
52
- it "can be a foss-packaged host using passenger" do
53
- host.uses_passenger!
54
- expect(host.is_pe?).to be_falsy
55
- expect(host.use_service_scripts?).to be_truthy
56
- expect(host.is_using_passenger?).to be_truthy
57
- expect(host.graceful_restarts?).to be_truthy
36
+ expect(host).not_to be_is_pe
58
37
  end
59
38
 
60
39
  it 'can be an AIO host' do
61
40
  options['type'] = 'aio'
62
- expect(host.is_pe?).to be_falsy
63
- expect(host.use_service_scripts?).to be_falsy
64
- expect(host.is_using_passenger?).to be_falsy
41
+ expect(host).not_to be_is_pe
65
42
  end
66
43
 
67
44
  it 'sets the paths correctly for an AIO host' do
@@ -70,52 +47,6 @@ module Beaker
70
47
  end
71
48
  end
72
49
 
73
- describe "uses_passenger!" do
74
- it "sets passenger property" do
75
- host.uses_passenger!
76
- expect(host['passenger']).to be_truthy
77
- expect(host.is_using_passenger?).to be_truthy
78
- end
79
-
80
- it "sets puppetservice" do
81
- host.uses_passenger!('servicescript')
82
- expect(host['puppetservice']).to eq('servicescript')
83
- end
84
-
85
- it "sets puppetservice to apache2 by default" do
86
- host.uses_passenger!
87
- expect(host['puppetservice']).to eq('apache2')
88
- end
89
- end
90
-
91
- describe "graceful_restarts?" do
92
- it "is true if graceful-restarts property is set true" do
93
- options['graceful-restarts'] = true
94
- expect(host.graceful_restarts?).to be_truthy
95
- end
96
-
97
- it "is false if graceful-restarts property is set false" do
98
- options['graceful-restarts'] = false
99
- expect(host.graceful_restarts?).to be_falsy
100
- end
101
-
102
- it "is false if is_pe and graceful-restarts is nil" do
103
- options['type'] = 'pe'
104
- expect(host.graceful_restarts?).to be_falsy
105
- end
106
-
107
- it "is true if is_pe and graceful-restarts is true" do
108
- options['type'] = 'pe'
109
- options['graceful-restarts'] = true
110
- expect(host.graceful_restarts?).to be_truthy
111
- end
112
-
113
- it "falls back to passenger property if not pe and graceful-restarts is nil" do
114
- host.uses_passenger!
115
- expect(host.graceful_restarts?).to be_truthy
116
- end
117
- end
118
-
119
50
  describe "windows hosts" do
120
51
  describe "install_package" do
121
52
  let(:cygwin) { 'setup-x86.exe' }
@@ -123,14 +54,13 @@ module Beaker
123
54
  let(:package) { 'foo' }
124
55
 
125
56
  context "testing osarchitecture" do
126
-
127
57
  context "64 bit" do
128
58
  before do
129
59
  @platform = Beaker::Platform.new('windows-2008r2-64')
130
60
  end
131
61
 
132
62
  it "uses 64 bit cygwin" do
133
- expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
63
+ expect(host).to receive(:execute).with(/#{cygwin64}.*#{package}/)
134
64
  host.install_package(package)
135
65
  end
136
66
  end
@@ -141,22 +71,20 @@ module Beaker
141
71
  end
142
72
 
143
73
  it "uses 32 bit cygwin" do
144
- expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
74
+ expect(host).to receive(:execute).with(/#{cygwin}.*#{package}/)
145
75
  host.install_package(package)
146
76
  end
147
77
  end
148
78
  end
149
-
150
79
  end
151
80
  end
152
81
 
153
82
  describe "#add_env_var" do
154
-
155
83
  it "does nothing if the key/value pair already exists" do
156
84
  result = Beaker::Result.new(host, '')
157
85
  result.exit_code = 0
158
- expect( Beaker::Command ).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
159
- expect( host ).to receive(:exec).once.and_return(result)
86
+ expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
87
+ expect(host).to receive(:exec).once.and_return(result)
160
88
 
161
89
  host.add_env_var('key', '/my/first/value')
162
90
  end
@@ -164,76 +92,74 @@ module Beaker
164
92
  it "adds new line to environment file if no env var of that name already exists" do
165
93
  result = Beaker::Result.new(host, '')
166
94
  result.exit_code = 1
167
- expect( Beaker::Command ).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
168
- expect( host ).to receive(:exec).and_return(result)
169
- expect( Beaker::Command ).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
170
- expect( host ).to receive(:exec).and_return(result)
171
- expect( Beaker::Command ).to receive(:new).with("echo \"key=/my/first/value\" >> ~/.ssh/environment")
95
+ expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
96
+ expect(host).to receive(:exec).and_return(result)
97
+ expect(Beaker::Command).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
98
+ expect(host).to receive(:exec).and_return(result)
99
+ expect(Beaker::Command).to receive(:new).with("echo \"key=/my/first/value\" >> ~/.ssh/environment")
172
100
  host.add_env_var('key', '/my/first/value')
173
101
  end
174
102
 
175
103
  it "updates existing line in environment file when adding additional value to existing variable" do
176
104
  result = Beaker::Result.new(host, '')
177
105
  result.exit_code = 1
178
- expect( Beaker::Command ).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
179
- expect( host ).to receive(:exec).and_return(result)
106
+ expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
107
+ expect(host).to receive(:exec).and_return(result)
180
108
  result = Beaker::Result.new(host, '')
181
109
  result.exit_code = 0
182
- expect( Beaker::Command ).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
183
- expect( host ).to receive(:exec).and_return(result)
184
- expect( Beaker::SedCommand ).to receive(:new).with('unix', 's/^key=/key=\\/my\\/first\\/value:/', '~/.ssh/environment')
110
+ expect(Beaker::Command).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
111
+ expect(host).to receive(:exec).and_return(result)
112
+ expect(Beaker::SedCommand).to receive(:new).with('unix', 's/^key=/key=\\/my\\/first\\/value:/', '~/.ssh/environment')
185
113
  host.add_env_var('key', '/my/first/value')
186
114
  end
187
-
188
115
  end
189
116
 
190
117
  describe "#delete_env_var" do
191
118
  it "deletes env var" do
192
- expect( Beaker::SedCommand ).to receive(:new).with('unix', '/key=\\/my\\/first\\/value$/d', '~/.ssh/environment')
193
- expect( Beaker::SedCommand ).to receive(:new).with("unix", "s/key=\\(.*\\)[;:]\\/my\\/first\\/value/key=\\1/", "~/.ssh/environment")
194
- expect( Beaker::SedCommand ).to receive(:new).with("unix", "s/key=\\/my\\/first\\/value[;:]/key=/", "~/.ssh/environment")
119
+ expect(Beaker::SedCommand).to receive(:new).with('unix', '/key=\\/my\\/first\\/value$/d', '~/.ssh/environment')
120
+ expect(Beaker::SedCommand).to receive(:new).with("unix", "s/key=\\(.*\\)[;:]\\/my\\/first\\/value/key=\\1/", "~/.ssh/environment")
121
+ expect(Beaker::SedCommand).to receive(:new).with("unix", "s/key=\\/my\\/first\\/value[;:]/key=/", "~/.ssh/environment")
195
122
  host.delete_env_var('key', '/my/first/value')
196
123
  end
197
-
198
124
  end
199
125
 
200
126
  describe "executing commands" do
201
127
  let(:command) { Beaker::Command.new('ls') }
202
- let(:host) { Beaker::Host.create('host', {}, make_host_opts('host', options.merge(platform))) }
128
+ let(:host) { described_class.create('host', {}, make_host_opts('host', options.merge(platform))) }
203
129
  let(:result) { Beaker::Result.new(host, 'ls') }
204
130
 
205
- before :each do
131
+ before do
206
132
  result.stdout = 'stdout'
207
133
  result.stderr = 'stderr'
208
134
 
209
135
  logger = double(:logger)
210
- allow( logger ).to receive(:host_output)
211
- allow( logger ).to receive(:debug)
212
- allow( logger ).to receive(:with_indent) { |&block| block.call }
136
+ allow(logger).to receive(:host_output)
137
+ allow(logger).to receive(:debug)
138
+ allow(logger).to receive(:with_indent).and_yield
213
139
  host.instance_variable_set :@logger, logger
214
140
  conn = double(:connection)
215
- allow( conn ).to receive(:execute).and_return(result)
216
- allow( conn ).to receive(:ip).and_return(host['ip'])
217
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
218
- allow( conn ).to receive(:hostname).and_return(host.name)
141
+ allow(conn).to receive(:execute).and_return(result)
142
+ allow(conn).to receive(:ip).and_return(host['ip'])
143
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
144
+ allow(conn).to receive(:hostname).and_return(host.name)
219
145
  host.instance_variable_set :@connection, conn
220
146
  end
221
147
 
222
148
  it 'takes a command object and a hash of options' do
223
149
  result.exit_code = 0
224
- expect{ host.exec(command, {}) }.to_not raise_error
150
+ expect { host.exec(command, {}) }.not_to raise_error
225
151
  end
226
152
 
227
153
  it 'acts on the host\'s logger and connection object' do
228
154
  result.exit_code = 0
229
- expect( host.instance_variable_get(:@logger) ).to receive(:debug).at_least(1).times
230
- expect( host.instance_variable_get(:@connection) ).to receive(:execute).once
155
+ expect(host.instance_variable_get(:@logger)).to receive(:debug).at_least(:once)
156
+ expect(host.instance_variable_get(:@connection)).to receive(:execute).once
231
157
  host.exec(command)
232
158
  end
233
159
 
234
160
  it 'returns the result object' do
235
161
  result.exit_code = 0
236
- expect( host.exec(command) ).to be === result
162
+ expect(host.exec(command)).to be === result
237
163
  end
238
164
 
239
165
  it 'logs the amount of time spent executing the command' do
@@ -241,7 +167,7 @@ module Beaker
241
167
 
242
168
  expect(host.logger).to receive(:debug).with(/executed in \d\.\d{2} seconds/)
243
169
 
244
- host.exec(command,{})
170
+ host.exec(command, {})
245
171
  end
246
172
 
247
173
  it 'raises a CommandFailure when an unacceptable exit code is returned' do
@@ -255,7 +181,7 @@ module Beaker
255
181
  result.exit_code = 7
256
182
  opts = {
257
183
  :acceptable_exit_codes => [0, 1],
258
- :accept_all_exit_codes => false
184
+ :accept_all_exit_codes => false,
259
185
  }
260
186
 
261
187
  expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
@@ -264,10 +190,10 @@ module Beaker
264
190
  it 'does throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
265
191
  result.exit_code = 7
266
192
  opts = {
267
- :acceptable_exit_codes => [0, 1],
268
- :accept_all_exit_codes => true
193
+ :acceptable_exit_codes => [0, 1],
194
+ :accept_all_exit_codes => true,
269
195
  }
270
- allow( host.logger ).to receive( :warn )
196
+ allow(host.logger).to receive(:warn)
271
197
 
272
198
  expect { host.exec(command, opts) }.to raise_error
273
199
  end
@@ -275,112 +201,110 @@ module Beaker
275
201
  it 'sends a warning when both :acceptable_exit_codes & :accept_all_exit_codes are set' do
276
202
  result.exit_code = 1
277
203
  opts = {
278
- :acceptable_exit_codes => [0, 1],
279
- :accept_all_exit_codes => true
204
+ :acceptable_exit_codes => [0, 1],
205
+ :accept_all_exit_codes => true,
280
206
  }
281
- expect( host.logger ).to receive( :warn ).with( /overrides/ )
207
+ expect(host.logger).to receive(:warn).with(/overrides/)
282
208
 
283
- expect { host.exec(command, opts) }.to_not raise_error
209
+ expect { host.exec(command, opts) }.not_to raise_error
284
210
  end
285
211
 
286
212
  it 'explicitly closes the connection when :reset_connection is set' do
287
- expect( host ).to receive( :close )
288
- expect { host.exec(command, :reset_connection => true) }.to_not raise_error
213
+ expect(host).to receive(:close)
214
+ expect { host.exec(command, :reset_connection => true) }.not_to raise_error
289
215
  end
290
216
 
291
217
  context "controls the result objects logging" do
292
218
  it "and passes a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
293
219
  result.exit_code = 0
294
- expect{ host.exec(command,{}) }.to_not raise_error
220
+ expect { host.exec(command, {}) }.not_to raise_error
295
221
  end
222
+
296
223
  it "and fails a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
297
224
  result.exit_code = 1
298
- expect{ host.exec(command,{}) }.to raise_error
225
+ expect { host.exec(command, {}) }.to raise_error
299
226
  end
227
+
300
228
  it "and passes a test if the exit_code matches :acceptable_exit_codes" do
301
229
  result.exit_code = 0
302
- expect{ host.exec(command,{:acceptable_exit_codes => 0}) }.to_not raise_error
230
+ expect { host.exec(command, { :acceptable_exit_codes => 0 }) }.not_to raise_error
303
231
  end
232
+
304
233
  it "and fails a test if the exit_code doesn't match :acceptable_exit_codes" do
305
234
  result.exit_code = 0
306
- expect{ host.exec(command,{:acceptable_exit_codes => 1}) }.to raise_error
235
+ expect { host.exec(command, { :acceptable_exit_codes => 1 }) }.to raise_error
307
236
  end
237
+
308
238
  it "and passes a test if the exit_code matches one of the :acceptable_exit_codes" do
309
239
  result.exit_code = 127
310
- expect{ host.exec(command,{:acceptable_exit_codes => [1,127]}) }.to_not raise_error
240
+ expect { host.exec(command, { :acceptable_exit_codes => [1, 127] }) }.not_to raise_error
311
241
  end
242
+
312
243
  it "and passes a test if the exit_code matches one of the range of :acceptable_exit_codes" do
313
244
  result.exit_code = 1
314
- expect{ host.exec(command,{:acceptable_exit_codes => (0..127)}) }.to_not raise_error
245
+ expect { host.exec(command, { :acceptable_exit_codes => (0..127) }) }.not_to raise_error
315
246
  end
316
247
  end
317
248
  end
318
249
 
319
250
  describe "#mkdir_p" do
320
-
321
251
  it "does the right thing on a bash host, identified as is_cygwin=true" do
322
- @options = {:is_cygwin => true}
252
+ @options = { :is_cygwin => true }
323
253
  @platform = 'windows'
324
254
  result = double
325
- allow( result ).to receive( :exit_code ).and_return( 0 )
326
- allow( host ).to receive( :exec ).and_return( result )
327
-
328
- expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
329
- expect( host.mkdir_p('test/test/test') ).to be == true
255
+ allow(result).to receive(:exit_code).and_return(0)
256
+ allow(host).to receive(:exec).and_return(result)
330
257
 
258
+ expect(Beaker::Command).to receive(:new).with("mkdir -p \"test/test/test\"")
259
+ expect(host.mkdir_p('test/test/test')).to be == true
331
260
  end
332
261
 
333
262
  it "does the right thing on a bash host, identified as is_cygwin=nil" do
334
- @options = {:is_cygwin => nil}
263
+ @options = { :is_cygwin => nil }
335
264
  @platform = 'windows'
336
265
  result = double
337
- allow( result ).to receive( :exit_code ).and_return( 0 )
338
- allow( host ).to receive( :exec ).and_return( result )
339
-
340
- expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
341
- expect( host.mkdir_p('test/test/test') ).to be == true
266
+ allow(result).to receive(:exit_code).and_return(0)
267
+ allow(host).to receive(:exec).and_return(result)
342
268
 
269
+ expect(Beaker::Command).to receive(:new).with("mkdir -p \"test/test/test\"")
270
+ expect(host.mkdir_p('test/test/test')).to be == true
343
271
  end
344
272
 
345
273
  it "does the right thing on a non-bash host, identified as is_cygwin=false (powershell)" do
346
- @options = {:is_cygwin => false}
274
+ @options = { :is_cygwin => false }
347
275
  @platform = 'windows'
348
276
  result = double
349
- allow( result ).to receive( :exit_code ).and_return( 0 )
350
- allow( host ).to receive( :exec ).and_return( result )
351
-
352
- expect( Beaker::Command ).to receive(:new).
353
- with("powershell.exe", ["-ExecutionPolicy Bypass",
354
- "-InputFormat None",
355
- "-NoLogo",
356
- "-NoProfile",
357
- "-NonInteractive",
358
- "-Command New-Item -Path 'test\\test\\test' -ItemType 'directory'"])
359
- expect( host.mkdir_p('test/test/test') ).to be == true
360
-
277
+ allow(result).to receive(:exit_code).and_return(0)
278
+ allow(host).to receive(:exec).and_return(result)
279
+
280
+ expect(Beaker::Command).to receive(:new)
281
+ .with("powershell.exe", ["-ExecutionPolicy Bypass",
282
+ "-InputFormat None",
283
+ "-NoLogo",
284
+ "-NoProfile",
285
+ "-NonInteractive",
286
+ "-Command New-Item -Path 'test\\test\\test' -ItemType 'directory'",])
287
+ expect(host.mkdir_p('test/test/test')).to be == true
361
288
  end
362
-
363
289
  end
364
290
 
365
291
  describe "#touch" do
366
-
367
292
  it "generates the right absolute command for a windows host" do
368
293
  @platform = 'windows'
369
- expect( host.touch('touched_file') ).to be == "c:\\\\windows\\\\system32\\\\cmd.exe /c echo. 2> touched_file"
294
+ expect(host.touch('touched_file')).to be == "c:\\\\windows\\\\system32\\\\cmd.exe /c echo. 2> touched_file"
370
295
  end
371
296
 
372
- ['centos','redhat'].each do |platform|
297
+ %w[centos redhat].each do |platform|
373
298
  it "generates the right absolute command for a #{platform} host" do
374
299
  @platform = platform
375
- expect( host.touch('touched_file') ).to be == "/bin/touch touched_file"
300
+ expect(host.touch('touched_file')).to be == "/bin/touch touched_file"
376
301
  end
377
302
  end
378
303
 
379
304
  it "generates the right absolute command for an osx host" do
380
305
  @platform = 'osx'
381
- expect( host.touch('touched_file') ).to be == "/usr/bin/touch touched_file"
306
+ expect(host.touch('touched_file')).to be == "/usr/bin/touch touched_file"
382
307
  end
383
-
384
308
  end
385
309
 
386
310
  context 'do_scp_to' do
@@ -392,16 +316,16 @@ module Beaker
392
316
  conn = double(:connection)
393
317
  @options = { :logger => logger }
394
318
  host.instance_variable_set :@connection, conn
395
- args = [ '/source', 'target', {} ]
319
+ args = ['/source', 'target', {}]
396
320
  conn_args = args
397
321
 
398
- expect( logger ).to receive(:trace)
399
- expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
400
- allow( conn ).to receive(:ip).and_return(host['ip'])
401
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
402
- allow( conn ).to receive(:hostname).and_return(host.name)
322
+ expect(logger).to receive(:trace)
323
+ expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
324
+ allow(conn).to receive(:ip).and_return(host['ip'])
325
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
326
+ allow(conn).to receive(:hostname).and_return(host.name)
403
327
 
404
- host.do_scp_to *args
328
+ host.do_scp_to(*args)
405
329
  end
406
330
 
407
331
  it 'calls for host scp post operations after SCPing happens' do
@@ -410,19 +334,19 @@ module Beaker
410
334
  conn = double(:connection)
411
335
  @options = { :logger => logger }
412
336
  host.instance_variable_set :@connection, conn
413
- args = [ '/source', 'target', {} ]
337
+ args = ['/source', 'target', {}]
414
338
  conn_args = args
415
339
 
416
- allow( logger ).to receive(:trace)
417
- expect( conn ).to receive(:scp_to).ordered.with(
418
- *conn_args
340
+ allow(logger).to receive(:trace)
341
+ expect(conn).to receive(:scp_to).ordered.with(
342
+ *conn_args,
419
343
  ).and_return(Beaker::Result.new(host, 'output!'))
420
- allow( conn ).to receive(:ip).and_return(host['ip'])
421
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
422
- allow( conn ).to receive(:hostname).and_return(host.name)
423
- expect( host ).to receive( :scp_post_operations ).ordered
344
+ allow(conn).to receive(:ip).and_return(host['ip'])
345
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
346
+ allow(conn).to receive(:hostname).and_return(host.name)
347
+ expect(host).to receive(:scp_post_operations).ordered
424
348
 
425
- host.do_scp_to *args
349
+ host.do_scp_to(*args)
426
350
  end
427
351
 
428
352
  it 'throws an IOError when the file given doesn\'t exist' do
@@ -430,38 +354,41 @@ module Beaker
430
354
  end
431
355
 
432
356
  context "using an ignore array with an absolute source path" do
433
- let( :source_path ) { '/repos/puppetlabs-inifile' }
434
- let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
357
+ let(:source_path) { '/repos/puppetlabs-inifile' }
358
+ let(:target_path) { '/etc/puppetlabs/modules/inifile' }
435
359
 
436
- before :each do
360
+ before do
437
361
  test_dir = "#{source_path}/tests"
438
362
  other_test_dir = "#{source_path}/tests2"
439
363
 
440
364
  files = [
441
- '00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
442
- '01_TestSetup.rb', '03_PuppetMasterSanity.rb',
443
- '06_InstallModules.rb','02_PuppetUserAndGroup.rb',
444
- '04_ValidateSignCert.rb', '07_InstallCACerts.rb' ]
365
+ '00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
366
+ '01_TestSetup.rb', '03_PuppetMasterSanity.rb',
367
+ '06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
368
+ '04_ValidateSignCert.rb', '07_InstallCACerts.rb',
369
+ ]
445
370
 
446
- @fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
447
- @fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
371
+ @fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
372
+ @fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
448
373
 
449
- create_files( @fileset1 )
450
- create_files( @fileset2 )
374
+ create_files(@fileset1)
375
+ create_files(@fileset2)
451
376
  end
377
+
452
378
  it 'can take an ignore list that excludes all files and not call scp_to' do
453
379
  logger = host[:logger]
454
380
  conn = double(:connection)
455
381
  @options = { :logger => logger }
456
382
  host.instance_variable_set :@connection, conn
457
- args = [ source_path, target_path, {:ignore => ['tests', 'tests2']} ]
383
+ args = [source_path, target_path, { :ignore => %w[tests tests2] }]
458
384
 
459
- expect( logger ).to receive(:trace)
460
- expect( host ).to receive( :mkdir_p ).exactly(0).times
461
- expect( conn ).to receive(:scp_to).exactly(0).times
385
+ expect(logger).to receive(:trace)
386
+ expect(host).to receive(:mkdir_p).exactly(0).times
387
+ expect(conn).to receive(:scp_to).exactly(0).times
462
388
 
463
- host.do_scp_to *args
389
+ host.do_scp_to(*args)
464
390
  end
391
+
465
392
  it 'can take an ignore list that excludes a single file and scp the rest' do
466
393
  created_target_path = File.join(target_path, File.basename(source_path))
467
394
  exclude_file = '07_InstallCACerts.rb'
@@ -469,110 +396,111 @@ module Beaker
469
396
  conn = double(:connection)
470
397
  @options = { :logger => logger }
471
398
  host.instance_variable_set :@connection, conn
472
- args = [ source_path, target_path, {:ignore => [exclude_file], :dry_run => false} ]
399
+ args = [source_path, target_path, { :ignore => [exclude_file], :dry_run => false }]
473
400
 
474
- allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
401
+ allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
475
402
 
476
- expect( logger ).to receive(:trace)
477
- expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests")
478
- expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests2")
403
+ expect(logger).to receive(:trace)
404
+ expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests")
405
+ expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests2")
479
406
 
480
407
  (@fileset1 + @fileset2).each do |file|
481
- if file !~ /#{exclude_file}/
482
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
408
+ if !/#{exclude_file}/.match?(file)
409
+ file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
483
410
  conn_args = file_args
484
- expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
411
+ expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
485
412
  else
486
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
413
+ file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
487
414
  conn_args = file_args
488
- expect( conn ).to_not receive(:scp_to).with( *conn_args )
415
+ expect(conn).not_to receive(:scp_to).with(*conn_args)
489
416
  end
490
417
  end
491
- allow( conn ).to receive(:ip).and_return(host['ip'])
492
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
493
- allow( conn ).to receive(:hostname).and_return(host.name)
418
+ allow(conn).to receive(:ip).and_return(host['ip'])
419
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
420
+ allow(conn).to receive(:hostname).and_return(host.name)
494
421
 
495
- host.do_scp_to *args
422
+ host.do_scp_to(*args)
496
423
  end
497
424
  end
498
425
 
499
426
  context "using an ignore array with an absolute source path in host root" do
500
- let( :source_path ) { '/puppetlabs-inifile' }
501
- let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
427
+ let(:source_path) { '/puppetlabs-inifile' }
428
+ let(:target_path) { '/etc/puppetlabs/modules/inifile' }
502
429
 
503
- before :each do
430
+ before do
504
431
  test_dir = "#{source_path}/tests"
505
432
  other_test_dir = "#{source_path}/tests/tests2"
506
433
  another_test_dir = "#{source_path}/tests/tests3"
507
434
 
508
435
  files = [
509
- '00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
510
- '01_TestSetup.rb', '03_PuppetMasterSanity.rb',
511
- '06_InstallModules.rb','02_PuppetUserAndGroup.rb',
512
- '04_ValidateSignCert.rb', '07_InstallCACerts.rb' ]
513
-
514
- @fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
515
- @fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
516
- @fileset3 = files.shuffle.map {|file| another_test_dir + '/' + file }
517
-
518
- create_files( @fileset1 )
519
- create_files( @fileset2 )
520
- create_files( @fileset3 )
436
+ '00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
437
+ '01_TestSetup.rb', '03_PuppetMasterSanity.rb',
438
+ '06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
439
+ '04_ValidateSignCert.rb', '07_InstallCACerts.rb',
440
+ ]
441
+
442
+ @fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
443
+ @fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
444
+ @fileset3 = files.shuffle.map { |file| another_test_dir + '/' + file }
445
+
446
+ create_files(@fileset1)
447
+ create_files(@fileset2)
448
+ create_files(@fileset3)
521
449
  end
522
450
 
523
- it "should create target dirs with correct path seperator" do
451
+ it "creates target dirs with correct path seperator" do
524
452
  create_files(['source'])
525
453
  exclude_file = '04_ValidateSignCert.rb'
526
454
  logger = host[:logger]
527
455
  conn = double(:connection)
528
456
  @options = { :logger => logger }
529
457
  host.instance_variable_set :@connection, conn
530
- args = [ source_path, target_path, {:ignore => [exclude_file]} ]
458
+ args = [source_path, target_path, { :ignore => [exclude_file] }]
531
459
  conn_args = args
532
460
 
533
- allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 + @fileset3)
461
+ allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2 + @fileset3)
534
462
 
535
463
  created_target_path = File.join(target_path, File.basename(source_path))
536
- expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests")
537
- expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests/tests2")
538
- expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests/tests3")
464
+ expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests")
465
+ expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests/tests2")
466
+ expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests/tests3")
539
467
 
540
468
  (@fileset1 + @fileset2 + @fileset3).each do |file|
541
- if file !~ /#{exclude_file}/
542
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
469
+ if !/#{exclude_file}/.match?(file)
470
+ file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
543
471
  conn_args = file_args
544
- expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
472
+ expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
545
473
  else
546
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
474
+ file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
547
475
  conn_args = file_args
548
- expect( conn ).to_not receive(:scp_to).with( *conn_args )
476
+ expect(conn).not_to receive(:scp_to).with(*conn_args)
549
477
  end
550
478
  end
551
- allow( conn ).to receive(:ip).and_return(host['ip'])
552
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
553
- allow( conn ).to receive(:hostname).and_return(host.name)
479
+ allow(conn).to receive(:ip).and_return(host['ip'])
480
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
481
+ allow(conn).to receive(:hostname).and_return(host.name)
554
482
 
555
- host.do_scp_to *args
483
+ host.do_scp_to(*args)
556
484
  end
557
485
  end
558
486
 
559
487
  context "using an ignore array" do
560
-
561
- before :each do
488
+ before do
562
489
  test_dir = 'tmp/tests'
563
490
  other_test_dir = 'tmp/tests2'
564
491
 
565
492
  files = [
566
493
  '00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
567
494
  '01_TestSetup.rb', '03_PuppetMasterSanity.rb',
568
- '06_InstallModules.rb','02_PuppetUserAndGroup.rb',
569
- '04_ValidateSignCert.rb', '07_InstallCACerts.rb' ]
495
+ '06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
496
+ '04_ValidateSignCert.rb', '07_InstallCACerts.rb',
497
+ ]
570
498
 
571
- @fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
572
- @fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
499
+ @fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
500
+ @fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
573
501
 
574
- create_files( @fileset1 )
575
- create_files( @fileset2 )
502
+ create_files(@fileset1)
503
+ create_files(@fileset2)
576
504
  end
577
505
 
578
506
  it 'can take an ignore list that excludes all files and not call scp_to' do
@@ -580,13 +508,13 @@ module Beaker
580
508
  conn = double(:connection)
581
509
  @options = { :logger => logger }
582
510
  host.instance_variable_set :@connection, conn
583
- args = [ 'tmp', 'target', {:ignore => ['tests', 'tests2']} ]
511
+ args = ['tmp', 'target', { :ignore => %w[tests tests2] }]
584
512
 
585
- expect( logger ).to receive(:trace)
586
- expect( host ).to receive( :mkdir_p ).exactly(0).times
587
- expect( conn ).to receive(:scp_to).exactly(0).times
513
+ expect(logger).to receive(:trace)
514
+ expect(host).to receive(:mkdir_p).exactly(0).times
515
+ expect(conn).to receive(:scp_to).exactly(0).times
588
516
 
589
- host.do_scp_to *args
517
+ host.do_scp_to(*args)
590
518
  end
591
519
 
592
520
  it 'can take an ignore list that excludes a single file and scp the rest' do
@@ -595,28 +523,28 @@ module Beaker
595
523
  conn = double(:connection)
596
524
  @options = { :logger => logger }
597
525
  host.instance_variable_set :@connection, conn
598
- args = [ 'tmp', 'target', {:ignore => [exclude_file], :dry_run => false} ]
526
+ args = ['tmp', 'target', { :ignore => [exclude_file], :dry_run => false }]
599
527
 
600
- allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
528
+ allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
601
529
 
602
- expect( logger ).to receive(:trace)
603
- expect( host ).to receive( :mkdir_p ).with('target/tmp/tests')
604
- expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
530
+ expect(logger).to receive(:trace)
531
+ expect(host).to receive(:mkdir_p).with('target/tmp/tests')
532
+ expect(host).to receive(:mkdir_p).with('target/tmp/tests2')
605
533
  (@fileset1 + @fileset2).each do |file|
606
- if file !~ /#{exclude_file}/
607
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
534
+ if !/#{exclude_file}/.match?(file)
535
+ file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
608
536
  conn_args = file_args
609
- expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
537
+ expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
610
538
  else
611
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
539
+ file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
612
540
  conn_args = file_args
613
- expect( conn ).to_not receive(:scp_to).with( *conn_args )
541
+ expect(conn).not_to receive(:scp_to).with(*conn_args)
614
542
  end
615
543
  end
616
- allow( conn ).to receive(:ip).and_return(host['ip'])
617
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
618
- allow( conn ).to receive(:hostname).and_return(host.name)
619
- host.do_scp_to *args
544
+ allow(conn).to receive(:ip).and_return(host['ip'])
545
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
546
+ allow(conn).to receive(:hostname).and_return(host.name)
547
+ host.do_scp_to(*args)
620
548
  end
621
549
 
622
550
  it 'can take an ignore list that excludes a dir and scp the rest' do
@@ -625,28 +553,28 @@ module Beaker
625
553
  conn = double(:connection)
626
554
  @options = { :logger => logger }
627
555
  host.instance_variable_set :@connection, conn
628
- args = [ 'tmp', 'target', {:ignore => [exclude_file], :dry_run => false} ]
556
+ args = ['tmp', 'target', { :ignore => [exclude_file], :dry_run => false }]
629
557
 
630
- allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
558
+ allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
631
559
 
632
- expect( logger ).to receive(:trace)
633
- expect( host ).to_not receive( :mkdir_p ).with('target/tmp/tests')
634
- expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
560
+ expect(logger).to receive(:trace)
561
+ expect(host).not_to receive(:mkdir_p).with('target/tmp/tests')
562
+ expect(host).to receive(:mkdir_p).with('target/tmp/tests2')
635
563
  (@fileset1).each do |file|
636
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
564
+ file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
637
565
  conn_args = file_args
638
- expect( conn ).to_not receive(:scp_to).with( *conn_args )
566
+ expect(conn).not_to receive(:scp_to).with(*conn_args)
639
567
  end
640
568
  (@fileset2).each do |file|
641
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
569
+ file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
642
570
  conn_args = file_args
643
- expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
571
+ expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
644
572
  end
645
573
 
646
- allow( conn ).to receive(:ip).and_return(host['ip'])
647
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
648
- allow( conn ).to receive(:hostname).and_return(host.name)
649
- host.do_scp_to *args
574
+ allow(conn).to receive(:ip).and_return(host['ip'])
575
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
576
+ allow(conn).to receive(:hostname).and_return(host.name)
577
+ host.do_scp_to(*args)
650
578
  end
651
579
  end
652
580
  end
@@ -657,16 +585,16 @@ module Beaker
657
585
  conn = double(:connection)
658
586
  @options = { :logger => logger }
659
587
  host.instance_variable_set :@connection, conn
660
- args = [ 'source', 'target', {} ]
588
+ args = ['source', 'target', {}]
661
589
  conn_args = args
662
590
 
663
- expect( logger ).to receive(:debug)
664
- expect( conn ).to receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
591
+ expect(logger).to receive(:debug)
592
+ expect(conn).to receive(:scp_from).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
665
593
 
666
- allow( conn ).to receive(:ip).and_return(host['ip'])
667
- allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
668
- allow( conn ).to receive(:hostname).and_return(host.name)
669
- host.do_scp_from *args
594
+ allow(conn).to receive(:ip).and_return(host['ip'])
595
+ allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
596
+ allow(conn).to receive(:hostname).and_return(host.name)
597
+ host.do_scp_from(*args)
670
598
  end
671
599
  end
672
600
 
@@ -675,18 +603,18 @@ module Beaker
675
603
  create_files(['source'])
676
604
  logger = host[:logger]
677
605
  @options = { :logger => logger }
678
- args = [ 'source', 'target', {:ignore => ['.bundle']} ]
606
+ args = ['source', 'target', { :ignore => ['.bundle'] }]
679
607
 
680
608
  key = host['ssh']['keys'].first
681
- expect( File ).to receive( :exist? ).with( key ).and_return true
609
+ expect(File).to receive(:exist?).with(key).and_return true
682
610
 
683
- rsync_args = [ 'source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"] ]
611
+ rsync_args = ['source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
684
612
 
685
- expect( host ).to receive(:reachable_name).and_return('default.ip.address')
613
+ expect(host).to receive(:reachable_name).and_return('default.ip.address')
686
614
 
687
- expect( Rsync ).to receive(:run).with( *rsync_args ).and_return(Rsync::Result.new('raw rsync output', 0))
615
+ expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
688
616
 
689
- host.do_rsync_to *args
617
+ host.do_rsync_to(*args)
690
618
 
691
619
  expect(Rsync.host).to eq('root@default.ip.address')
692
620
  end
@@ -696,24 +624,24 @@ module Beaker
696
624
  end
697
625
 
698
626
  it 'uses the ssh config file' do
699
- @options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
627
+ @options = { 'ssh' => { :config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86' } }
700
628
  create_files(['source'])
701
- args = [ 'source', 'target',
702
- {:ignore => ['.bundle']} ]
629
+ args = ['source', 'target',
630
+ { :ignore => ['.bundle'] },]
703
631
  # since were using fakefs we need to create the file and directories
704
632
  FileUtils.mkdir_p('/var/folders/v0/')
705
633
  FileUtils.touch('/var/folders/v0/centos-64-x6420150625-48025-lu3u86')
706
- rsync_args = [ 'source', 'target', ['-az', "-e \"ssh -F /var/folders/v0/centos-64-x6420150625-48025-lu3u86 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"] ]
634
+ rsync_args = ['source', 'target', ['-az', "-e \"ssh -F /var/folders/v0/centos-64-x6420150625-48025-lu3u86 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
707
635
  expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
708
636
  expect(host.do_rsync_to(*args).success?).to eq(true)
709
637
  end
710
638
 
711
639
  it 'does not use the ssh config file when config does not exist' do
712
- @options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
640
+ @options = { 'ssh' => { :config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86' } }
713
641
  create_files(['source'])
714
- args = [ 'source', 'target',
715
- {:ignore => ['.bundle']} ]
716
- rsync_args = [ 'source', 'target', ['-az', "-e \"ssh -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"] ]
642
+ args = ['source', 'target',
643
+ { :ignore => ['.bundle'] },]
644
+ rsync_args = ['source', 'target', ['-az', "-e \"ssh -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
717
645
  expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
718
646
  expect(host.do_rsync_to(*args).success?).to eq(true)
719
647
  end
@@ -722,21 +650,21 @@ module Beaker
722
650
  create_files(['source'])
723
651
 
724
652
  ignore_list = ['.bundle']
725
- args = ['source', 'target', {:ignore => ignore_list}]
653
+ args = ['source', 'target', { :ignore => ignore_list }]
726
654
 
727
655
  key = host['ssh']['keys'].first
728
- expect( File ).to receive( :exist? ).with( key ).twice.and_return true
656
+ expect(File).to receive(:exist?).with(key).twice.and_return true
729
657
 
730
658
  rsync_args = ['source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
731
659
  expect(Rsync).to receive(:run).twice.with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
732
660
 
733
- host.do_rsync_to *args
734
- host.do_rsync_to *args
661
+ host.do_rsync_to(*args)
662
+ host.do_rsync_to(*args)
735
663
  end
736
664
  end
737
665
 
738
666
  it 'interpolates to its "name"' do
739
- expect( "#{host}" ).to be === 'name'
667
+ expect("#{host}").to be === 'name'
740
668
  end
741
669
 
742
670
  describe 'host close' do
@@ -746,14 +674,16 @@ module Beaker
746
674
  host.instance_variable_set :@connection, conn
747
675
  allow(host).to receive(:close).and_call_original
748
676
  end
677
+
749
678
  it 'does not raise an error' do
750
- expect { host.close }.to_not raise_error
679
+ expect { host.close }.not_to raise_error
751
680
  end
752
681
  end
753
682
  end
754
683
 
755
684
  describe '#get_public_ip' do
756
- let (:aws) { double('AWSmock')}
685
+ let(:aws) { double('AWSmock') }
686
+
757
687
  it 'calls upon the ec2 instance to get the ip address' do
758
688
  host.host_hash[:hypervisor] = 'ec2'
759
689
  host.host_hash[:instance] = aws
@@ -768,7 +698,7 @@ module Beaker
768
698
 
769
699
  it 'returns nil when no matching hypervisor is found' do
770
700
  host.host_hash[:hypervisor] = 'vmpooler'
771
- expect(host.get_public_ip).to be(nil)
701
+ expect(host.get_public_ip).to be_nil
772
702
  end
773
703
 
774
704
  it 'calls execute with curl if the host_hash[:instance] is not defined for ec2 and the host is not an instance of Windows::Host' do
@@ -802,19 +732,18 @@ module Beaker
802
732
  expect(host).to receive(:execute).with("wget http://169.254.169.254/latest/meta-data/public-ipv4").and_return('127.0.0.1')
803
733
  host.get_public_ip
804
734
  end
805
-
806
735
  end
807
736
 
808
737
  describe '#ip' do
809
738
  it 'calls #get_ip when get_public_ip returns nil' do
810
- allow( host ).to receive(:get_public_ip).and_return(nil)
739
+ allow(host).to receive(:get_public_ip).and_return(nil)
811
740
  expect(host).to receive(:get_ip).and_return('127.0.0.2')
812
741
  expect(host.ip).to eq('127.0.0.2')
813
742
  end
814
743
 
815
744
  it 'does not call get_ip when #get_public_ip returns an address' do
816
- allow( host ).to receive(:get_public_ip).and_return('127.0.0.1')
817
- expect(host).to_not receive(:get_ip)
745
+ allow(host).to receive(:get_public_ip).and_return('127.0.0.1')
746
+ expect(host).not_to receive(:get_ip)
818
747
  expect(host.ip).to eq('127.0.0.1')
819
748
  end
820
749
  end
@@ -838,7 +767,7 @@ module Beaker
838
767
  expect(host.fips_mode?).to be false
839
768
  end
840
769
 
841
- platforms = ['el-7', 'el-8', 'centos']
770
+ platforms = %w[el-7 el-8 centos]
842
771
 
843
772
  platforms.each do |platform|
844
773
  context "on #{platform}" do