beaker 4.41.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) 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 +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +16 -52
  8. data/Gemfile +12 -7
  9. data/HISTORY.md +605 -0
  10. data/Rakefile +99 -111
  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/Rakefile +1 -1
  16. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  17. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  18. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  19. data/acceptance/lib/helpers/test_helper.rb +6 -5
  20. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  21. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  22. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  23. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  41. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  42. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  43. data/acceptance/tests/base/host/file_test.rb +2 -2
  44. data/acceptance/tests/base/host/group_test.rb +0 -1
  45. data/acceptance/tests/base/host/host_test.rb +66 -63
  46. data/acceptance/tests/base/host/packages.rb +1 -2
  47. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  48. data/acceptance/tests/base/host/user_test.rb +0 -1
  49. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  50. data/acceptance/tests/base/test_suite/export.rb +6 -9
  51. data/acceptance/tests/install/from_file.rb +2 -4
  52. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  53. data/acceptance/tests/subcommands/destroy.rb +19 -21
  54. data/acceptance/tests/subcommands/exec.rb +0 -1
  55. data/acceptance/tests/subcommands/init.rb +2 -3
  56. data/acceptance/tests/subcommands/provision.rb +0 -1
  57. data/beaker.gemspec +4 -7
  58. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  59. data/docs/how_to/debug_beaker_tests.md +12 -12
  60. data/docs/how_to/hosts/eos.md +2 -12
  61. data/docs/how_to/install_puppet.md +0 -18
  62. data/docs/how_to/the_beaker_dsl.md +0 -2
  63. data/lib/beaker/cli.rb +59 -68
  64. data/lib/beaker/command.rb +20 -28
  65. data/lib/beaker/command_factory.rb +3 -2
  66. data/lib/beaker/dsl/assertions.rb +6 -18
  67. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  68. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  69. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  70. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  71. data/lib/beaker/dsl/helpers.rb +2 -4
  72. data/lib/beaker/dsl/outcomes.rb +13 -15
  73. data/lib/beaker/dsl/patterns.rb +1 -3
  74. data/lib/beaker/dsl/roles.rb +17 -20
  75. data/lib/beaker/dsl/structure.rb +53 -65
  76. data/lib/beaker/dsl/test_tagging.rb +7 -10
  77. data/lib/beaker/dsl/wrappers.rb +15 -16
  78. data/lib/beaker/dsl.rb +2 -3
  79. data/lib/beaker/host/aix/exec.rb +1 -1
  80. data/lib/beaker/host/aix/file.rb +0 -1
  81. data/lib/beaker/host/aix/group.rb +1 -1
  82. data/lib/beaker/host/aix/user.rb +1 -1
  83. data/lib/beaker/host/aix.rb +3 -4
  84. data/lib/beaker/host/cisco.rb +27 -39
  85. data/lib/beaker/host/eos.rb +4 -30
  86. data/lib/beaker/host/freebsd/exec.rb +1 -1
  87. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  88. data/lib/beaker/host/freebsd.rb +9 -12
  89. data/lib/beaker/host/mac/exec.rb +4 -4
  90. data/lib/beaker/host/mac/group.rb +7 -7
  91. data/lib/beaker/host/mac/pkg.rb +3 -106
  92. data/lib/beaker/host/mac/user.rb +2 -2
  93. data/lib/beaker/host/mac.rb +8 -9
  94. data/lib/beaker/host/pswindows/exec.rb +66 -70
  95. data/lib/beaker/host/pswindows/file.rb +3 -5
  96. data/lib/beaker/host/pswindows/group.rb +3 -3
  97. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  98. data/lib/beaker/host/pswindows/user.rb +3 -3
  99. data/lib/beaker/host/pswindows.rb +4 -3
  100. data/lib/beaker/host/unix/exec.rb +81 -83
  101. data/lib/beaker/host/unix/file.rb +40 -45
  102. data/lib/beaker/host/unix/group.rb +1 -1
  103. data/lib/beaker/host/unix/pkg.rb +138 -401
  104. data/lib/beaker/host/unix/user.rb +2 -2
  105. data/lib/beaker/host/unix.rb +8 -11
  106. data/lib/beaker/host/windows/exec.rb +17 -17
  107. data/lib/beaker/host/windows/file.rb +3 -3
  108. data/lib/beaker/host/windows/group.rb +3 -3
  109. data/lib/beaker/host/windows/pkg.rb +3 -54
  110. data/lib/beaker/host/windows/user.rb +3 -3
  111. data/lib/beaker/host/windows.rb +12 -12
  112. data/lib/beaker/host.rb +76 -133
  113. data/lib/beaker/host_prebuilt_steps.rb +88 -196
  114. data/lib/beaker/hypervisor/noop.rb +2 -4
  115. data/lib/beaker/hypervisor.rb +44 -61
  116. data/lib/beaker/local_connection.rb +2 -4
  117. data/lib/beaker/logger.rb +68 -76
  118. data/lib/beaker/logger_junit.rb +21 -25
  119. data/lib/beaker/network_manager.rb +39 -42
  120. data/lib/beaker/options/command_line_parser.rb +12 -23
  121. data/lib/beaker/options/hosts_file_parser.rb +16 -25
  122. data/lib/beaker/options/options_file_parser.rb +3 -6
  123. data/lib/beaker/options/options_hash.rb +2 -7
  124. data/lib/beaker/options/parser.rb +86 -102
  125. data/lib/beaker/options/presets.rb +114 -123
  126. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  127. data/lib/beaker/options/validator.rb +26 -31
  128. data/lib/beaker/perf.rb +25 -30
  129. data/lib/beaker/platform.rb +26 -37
  130. data/lib/beaker/result.rb +7 -6
  131. data/lib/beaker/shared/error_handler.rb +8 -10
  132. data/lib/beaker/shared/fog_credentials.rb +5 -9
  133. data/lib/beaker/shared/host_manager.rb +36 -41
  134. data/lib/beaker/shared/options_resolver.rb +3 -7
  135. data/lib/beaker/shared/repetition.rb +2 -4
  136. data/lib/beaker/shared/semvar.rb +37 -41
  137. data/lib/beaker/shared/timed.rb +0 -3
  138. data/lib/beaker/shared.rb +1 -1
  139. data/lib/beaker/ssh_connection.rb +38 -47
  140. data/lib/beaker/subcommand.rb +17 -24
  141. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  142. data/lib/beaker/tasks/quick_start.rb +4 -9
  143. data/lib/beaker/tasks/rake_task.rb +25 -27
  144. data/lib/beaker/tasks/test.rb +4 -4
  145. data/lib/beaker/test_case.rb +16 -28
  146. data/lib/beaker/test_suite.rb +35 -39
  147. data/lib/beaker/test_suite_result.rb +45 -47
  148. data/lib/beaker/version.rb +1 -1
  149. data/lib/beaker.rb +6 -7
  150. data/spec/beaker/cli_spec.rb +121 -142
  151. data/spec/beaker/command_spec.rb +55 -59
  152. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  153. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  154. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  155. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  156. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  157. data/spec/beaker/dsl/roles_spec.rb +125 -130
  158. data/spec/beaker/dsl/structure_spec.rb +172 -161
  159. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  160. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  161. data/spec/beaker/host/aix_spec.rb +14 -14
  162. data/spec/beaker/host/cisco_spec.rb +84 -94
  163. data/spec/beaker/host/eos_spec.rb +15 -36
  164. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  165. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  166. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  167. data/spec/beaker/host/mac/group_spec.rb +48 -57
  168. data/spec/beaker/host/mac/user_spec.rb +54 -63
  169. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  170. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  171. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  172. data/spec/beaker/host/pswindows_spec.rb +13 -13
  173. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  174. data/spec/beaker/host/unix/file_spec.rb +66 -71
  175. data/spec/beaker/host/unix/pkg_spec.rb +150 -411
  176. data/spec/beaker/host/unix_spec.rb +11 -207
  177. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  178. data/spec/beaker/host/windows/file_spec.rb +18 -19
  179. data/spec/beaker/host/windows/group_spec.rb +10 -12
  180. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  181. data/spec/beaker/host/windows/user_spec.rb +17 -23
  182. data/spec/beaker/host/windows_spec.rb +39 -39
  183. data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
  184. data/spec/beaker/host_spec.rb +204 -284
  185. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  186. data/spec/beaker/localhost_connection_spec.rb +10 -11
  187. data/spec/beaker/logger_junit_spec.rb +19 -30
  188. data/spec/beaker/logger_spec.rb +153 -136
  189. data/spec/beaker/network_manager_spec.rb +23 -23
  190. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  191. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  192. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  193. data/spec/beaker/options/options_hash_spec.rb +4 -6
  194. data/spec/beaker/options/parser_spec.rb +167 -167
  195. data/spec/beaker/options/presets_spec.rb +7 -9
  196. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  197. data/spec/beaker/options/validator_spec.rb +10 -11
  198. data/spec/beaker/perf_spec.rb +18 -21
  199. data/spec/beaker/platform_spec.rb +25 -50
  200. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  201. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  202. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  203. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  204. data/spec/beaker/shared/repetition_spec.rb +17 -24
  205. data/spec/beaker/shared/semvar_spec.rb +21 -26
  206. data/spec/beaker/ssh_connection_spec.rb +76 -83
  207. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  208. data/spec/beaker/subcommand_spec.rb +75 -77
  209. data/spec/beaker/test_case_spec.rb +25 -50
  210. data/spec/beaker/test_suite_spec.rb +147 -154
  211. data/spec/helpers.rb +39 -45
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +8 -24
  216. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  217. data/acceptance/tests/base/external_resources_test.rb +0 -31
  218. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -5,202 +5,198 @@ module Beaker
5
5
  describe SshConnection do
6
6
  subject(:connection) { described_class.new name_hash, user, ssh_opts, options }
7
7
 
8
- let( :user ) { 'root' }
9
- let( :ssh_opts ) { { keepalive: true, keepalive_interval: 2 } }
10
- let( :options ) { { :logger => double('logger').as_null_object, :ssh_connection_preference => [:ip, :vmhostname, :hostname]} }
11
- let( :ip ) { "default.ip.address" }
12
- let( :vmhostname ){ "vmhostname" }
13
- let( :hostname) { "my_host" }
14
- let( :name_hash ) { { :ip => ip, :vmhostname => vmhostname, :hostname => hostname } }
15
-
8
+ let(:user) { 'root' }
9
+ let(:ssh_opts) { { keepalive: true, keepalive_interval: 2 } }
10
+ let(:options) { { :logger => double('logger').as_null_object, :ssh_connection_preference => %i[ip vmhostname hostname] } }
11
+ let(:ip) { "default.ip.address" }
12
+ let(:vmhostname) { "vmhostname" }
13
+ let(:hostname) { "my_host" }
14
+ let(:name_hash) { { :ip => ip, :vmhostname => vmhostname, :hostname => hostname } }
16
15
 
17
16
  before do
18
- allow( subject ).to receive(:sleep)
17
+ allow(subject).to receive(:sleep)
19
18
  end
20
19
 
21
20
  it 'self.connect creates connects and returns a proxy for that connection' do
22
- expect( Net::SSH ).to receive(:start).with( "default.ip.address", user, ssh_opts ).and_return(true)
21
+ expect(Net::SSH).to receive(:start).with("default.ip.address", user, ssh_opts).and_return(true)
23
22
  connection_constructor = described_class.connect name_hash, user, ssh_opts, options
24
- expect( connection_constructor ).to be_a_kind_of described_class
23
+ expect(connection_constructor).to be_a described_class
25
24
  end
26
25
 
27
26
  it 'connect creates a new connection' do
28
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(true)
27
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts).and_return(true)
29
28
  connection.connect
30
29
  end
31
30
 
32
31
  it 'connect caches its connection' do
33
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts ).once.and_return true
32
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts).once.and_return true
34
33
  connection.connect
35
34
  end
36
35
 
37
36
  it 'attempts to connect by vmhostname address if ip connection fails' do
38
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(false)
39
- expect( Net::SSH ).to receive( :start ).with( vmhostname, user, ssh_opts).and_return(true).once
40
- expect( Net::SSH ).not_to receive( :start ).with( hostname, user, ssh_opts)
37
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts).and_return(false)
38
+ expect(Net::SSH).to receive(:start).with(vmhostname, user, ssh_opts).and_return(true).once
39
+ expect(Net::SSH).not_to receive(:start).with(hostname, user, ssh_opts)
41
40
  connection.connect
42
41
  end
43
42
 
44
43
  it 'attempts to connect by hostname, if vmhost + ipaddress have failed' do
45
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(false)
46
- expect( Net::SSH ).to receive( :start ).with( vmhostname, user, ssh_opts).and_return(false)
47
- expect( Net::SSH ).to receive( :start ).with( hostname, user, ssh_opts).and_return(true).once
44
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts).and_return(false)
45
+ expect(Net::SSH).to receive(:start).with(vmhostname, user, ssh_opts).and_return(false)
46
+ expect(Net::SSH).to receive(:start).with(hostname, user, ssh_opts).and_return(true).once
48
47
  connection.connect
49
-
50
48
  end
51
49
 
52
50
  describe '#close' do
53
-
54
51
  it 'runs ssh close' do
55
52
  mock_ssh = Object.new
56
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
53
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
57
54
  connection.connect
58
55
 
59
- allow( mock_ssh).to receive( :closed? ).once.and_return(false)
60
- expect( mock_ssh ).to receive( :close ).once
56
+ allow(mock_ssh).to receive(:closed?).once.and_return(false)
57
+ expect(mock_ssh).to receive(:close).once
61
58
  connection.close
62
59
  end
63
60
 
64
61
  it 'sets the @ssh variable to nil' do
65
62
  mock_ssh = Object.new
66
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
63
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
67
64
  connection.connect
68
65
 
69
- allow( mock_ssh).to receive( :closed? ).once.and_return(false)
70
- expect( mock_ssh ).to receive( :close ).once
66
+ allow(mock_ssh).to receive(:closed?).once.and_return(false)
67
+ expect(mock_ssh).to receive(:close).once
71
68
  connection.close
72
69
 
73
- expect( connection.instance_variable_get(:@ssh) ).to be_nil
70
+ expect(connection.instance_variable_get(:@ssh)).to be_nil
74
71
  end
75
72
 
76
73
  it 'calls ssh shutdown & re-raises if ssh close fails with an unexpected Error' do
77
74
  mock_ssh = Object.new
78
- allow( mock_ssh ).to receive( :close ) { raise StandardError }
79
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
75
+ allow(mock_ssh).to receive(:close) { raise StandardError }
76
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
80
77
  connection.connect
81
78
 
82
- allow( mock_ssh).to receive( :closed? ).once.and_return(false)
83
- expect( mock_ssh ).to receive( :shutdown! ).once
84
- expect{ connection.close }.to raise_error(StandardError)
85
- expect( connection.instance_variable_get(:@ssh) ).to be_nil
79
+ allow(mock_ssh).to receive(:closed?).once.and_return(false)
80
+ expect(mock_ssh).to receive(:shutdown!).once
81
+ expect { connection.close }.to raise_error(StandardError)
82
+ expect(connection.instance_variable_get(:@ssh)).to be_nil
86
83
  end
87
-
88
84
  end
89
85
 
90
86
  describe '#execute' do
91
87
  it 'raises an error if it fails' do
92
88
  mock_ssh = Object.new
93
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
89
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
94
90
  connection.connect
95
91
 
96
- allow( subject ).to receive( :try_to_execute ) { raise Timeout::Error }
92
+ allow(subject).to receive(:try_to_execute) { raise Timeout::Error }
97
93
 
98
- expect{ connection.execute('ls') }.to raise_error Timeout::Error
94
+ expect { connection.execute('ls') }.to raise_error Timeout::Error
99
95
  end
100
96
  end
101
97
 
102
98
  describe '#request_terminal_for' do
103
99
  it 'fails correctly by raising Net::SSH::Exception' do
104
100
  mock_ssh = Object.new
105
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
101
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
106
102
  connection.connect
107
103
 
108
104
  mock_channel = Object.new
109
- allow( mock_channel ).to receive( :request_pty ).and_yield(nil, false)
105
+ allow(mock_channel).to receive(:request_pty).and_yield(nil, false)
110
106
 
111
- expect{ connection.request_terminal_for mock_channel, 'ls' }.to raise_error Net::SSH::Exception
107
+ expect { connection.request_terminal_for mock_channel, 'ls' }.to raise_error Net::SSH::Exception
112
108
  end
113
109
  end
114
110
 
115
111
  describe '#register_stdout_for' do
116
112
  before do
117
113
  @mock_ssh = Object.new
118
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
114
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { @mock_ssh }
119
115
  connection.connect
120
116
 
121
117
  @data = '7 of clubs'
122
118
  @mock_channel = Object.new
123
- allow( @mock_channel ).to receive( :on_data ).and_yield(nil, @data)
119
+ allow(@mock_channel).to receive(:on_data).and_yield(nil, @data)
124
120
 
125
121
  @mock_output = Object.new
126
122
  @mock_output_stdout = Object.new
127
123
  @mock_output_output = Object.new
128
- allow( @mock_output ).to receive( :stdout ) { @mock_output_stdout }
129
- allow( @mock_output ).to receive( :output ) { @mock_output_output }
130
- allow( @mock_output_stdout ).to receive( :<< )
131
- allow( @mock_output_output ).to receive( :<< )
124
+ allow(@mock_output).to receive(:stdout) { @mock_output_stdout }
125
+ allow(@mock_output).to receive(:output) { @mock_output_output }
126
+ allow(@mock_output_stdout).to receive(:<<)
127
+ allow(@mock_output_output).to receive(:<<)
132
128
  end
133
129
 
134
130
  it 'puts data into stdout & output correctly' do
135
- expect( @mock_output_stdout ).to receive( :<< ).with(@data)
136
- expect( @mock_output_output ).to receive( :<< ).with(@data)
131
+ expect(@mock_output_stdout).to receive(:<<).with(@data)
132
+ expect(@mock_output_output).to receive(:<<).with(@data)
137
133
 
138
134
  connection.register_stdout_for @mock_channel, @mock_output
139
135
  end
140
136
 
141
137
  it 'calls the callback if given' do
142
138
  @mock_callback = Object.new
143
- expect( @mock_callback ).to receive( :[] ).with(@data)
139
+ expect(@mock_callback).to receive(:[]).with(@data)
144
140
 
145
141
  connection.register_stdout_for @mock_channel, @mock_output, @mock_callback
146
142
  end
147
143
  end
148
144
 
149
145
  describe '#register_stderr_for' do
150
- let( :result ) { Beaker::Result.new('hostname', 'command') }
146
+ let(:result) { Beaker::Result.new('hostname', 'command') }
151
147
 
152
148
  before do
153
149
  @mock_ssh = Object.new
154
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
150
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { @mock_ssh }
155
151
  connection.connect
156
152
 
157
153
  @data = '3 of spades'
158
154
  @mock_channel = Object.new
159
- allow( @mock_channel ).to receive( :on_extended_data ).and_yield(nil, 1, @data)
155
+ allow(@mock_channel).to receive(:on_extended_data).and_yield(nil, 1, @data)
160
156
  end
161
157
 
162
158
  it 'puts data into stderr & output correctly' do
163
- expect( result.stderr ).to receive( :<< ).with(@data)
164
- expect( result.output ).to receive( :<< ).with(@data)
159
+ expect(result.stderr).to receive(:<<).with(@data)
160
+ expect(result.output).to receive(:<<).with(@data)
165
161
 
166
162
  connection.register_stderr_for @mock_channel, result
167
163
  end
168
164
 
169
165
  it 'calls the callback if given' do
170
166
  @mock_callback = Object.new
171
- expect( @mock_callback ).to receive( :[] ).with(@data)
167
+ expect(@mock_callback).to receive(:[]).with(@data)
172
168
 
173
169
  connection.register_stderr_for @mock_channel, result, @mock_callback
174
170
  end
175
171
 
176
172
  it 'skips everything if type is not 1' do
177
- allow( @mock_channel ).to receive( :on_extended_data ).and_yield(nil, '1', @data)
173
+ allow(@mock_channel).to receive(:on_extended_data).and_yield(nil, '1', @data)
178
174
 
179
175
  @mock_callback = Object.new
180
- expect( @mock_callback ).not_to receive( :[] )
181
- expect( result.stderr ).not_to receive( :<< )
182
- expect( result.output ).not_to receive( :<< )
176
+ expect(@mock_callback).not_to receive(:[])
177
+ expect(result.stderr).not_to receive(:<<)
178
+ expect(result.output).not_to receive(:<<)
183
179
 
184
180
  connection.register_stderr_for @mock_channel, result, @mock_callback
185
181
  end
186
182
  end
187
183
 
188
184
  describe '#register_exit_code_for' do
189
- let( :result ) { Beaker::Result.new('hostname', 'command') }
185
+ let(:result) { Beaker::Result.new('hostname', 'command') }
190
186
 
191
187
  it 'assigns the output\'s exit code correctly from the data' do
192
188
  mock_ssh = Object.new
193
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
189
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { mock_ssh }
194
190
  connection.connect
195
191
 
196
192
  data = '10 of jeromes'
197
193
  mock_data = Object.new
198
- allow( mock_data ).to receive( :read_long ) { data }
194
+ allow(mock_data).to receive(:read_long) { data }
199
195
  mock_channel = Object.new
200
- allow( mock_channel ).to receive( :on_request ).with('exit-status').and_yield(nil, mock_data)
196
+ allow(mock_channel).to receive(:on_request).with('exit-status').and_yield(nil, mock_data)
201
197
 
202
198
  connection.register_exit_code_for mock_channel, result
203
- expect( result.exit_code ).to be === data
199
+ expect(result.exit_code).to be === data
204
200
  end
205
201
  end
206
202
 
@@ -209,9 +205,9 @@ module Beaker
209
205
  stdin = 'jean shorts'
210
206
  mock_channel = Object.new
211
207
 
212
- expect( mock_channel ).to receive( :send_data ).with(stdin).ordered.once
213
- expect( mock_channel ).to receive( :process ).ordered.once
214
- expect( mock_channel ).to receive( :eof! ).ordered.once
208
+ expect(mock_channel).to receive(:send_data).with(stdin).ordered.once
209
+ expect(mock_channel).to receive(:process).ordered.once
210
+ expect(mock_channel).to receive(:eof!).ordered.once
215
211
 
216
212
  connection.process_stdin_for mock_channel, stdin
217
213
  end
@@ -221,55 +217,52 @@ module Beaker
221
217
  before do
222
218
  @mock_ssh = Object.new
223
219
  @mock_scp = Object.new
224
- allow( @mock_scp ).to receive( :upload! )
225
- allow( @mock_ssh ).to receive( :scp ).and_return( @mock_scp )
226
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
220
+ allow(@mock_scp).to receive(:upload!)
221
+ allow(@mock_ssh).to receive(:scp).and_return(@mock_scp)
222
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { @mock_ssh }
227
223
  connection.connect
228
224
  end
229
225
 
230
226
  it 'calls scp.upload!' do
231
- expect( @mock_scp ).to receive( :upload! ).once
227
+ expect(@mock_scp).to receive(:upload!).once
232
228
  connection.scp_to '', ''
233
229
  end
234
230
 
235
231
  it 'ensures the connection closes when scp.upload! errors' do
236
- expect( @mock_scp ).to receive( :upload! ).once.and_raise(RuntimeError)
232
+ expect(@mock_scp).to receive(:upload!).once.and_raise(RuntimeError)
237
233
  expect(connection).to receive(:close).once
238
234
  connection.scp_to '', ''
239
235
  end
240
236
 
241
237
  it 'returns a result object' do
242
- expect( connection.scp_to '', '' ).to be_a_kind_of Beaker::Result
238
+ expect(connection.scp_to '', '').to be_a Beaker::Result
243
239
  end
244
-
245
240
  end
246
241
 
247
242
  describe '#scp_from' do
248
243
  before do
249
244
  @mock_ssh = Object.new
250
245
  @mock_scp = Object.new
251
- allow( @mock_scp ).to receive( :download! )
252
- allow( @mock_ssh ).to receive( :scp ).and_return( @mock_scp )
253
- expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
246
+ allow(@mock_scp).to receive(:download!)
247
+ allow(@mock_ssh).to receive(:scp).and_return(@mock_scp)
248
+ expect(Net::SSH).to receive(:start).with(ip, user, ssh_opts) { @mock_ssh }
254
249
  connection.connect
255
250
  end
256
251
 
257
252
  it 'calls scp.download!' do
258
- expect( @mock_scp ).to receive( :download! ).once
253
+ expect(@mock_scp).to receive(:download!).once
259
254
  connection.scp_from '', ''
260
255
  end
261
256
 
262
257
  it 'ensures the connection closes when scp.download! errors' do
263
- expect( @mock_scp ).to receive( :download! ).once.and_raise(RuntimeError)
258
+ expect(@mock_scp).to receive(:download!).once.and_raise(RuntimeError)
264
259
  expect(connection).to receive(:close).once
265
260
  connection.scp_from '', ''
266
261
  end
267
262
 
268
263
  it 'returns a result object' do
269
- expect( connection.scp_from '', '' ).to be_a_kind_of Beaker::Result
264
+ expect(connection.scp_from '', '').to be_a Beaker::Result
270
265
  end
271
-
272
266
  end
273
-
274
267
  end
275
268
  end
@@ -3,58 +3,57 @@ require 'spec_helper'
3
3
  module Beaker
4
4
  module Subcommands
5
5
  describe SubcommandUtil do
6
-
7
- let(:cli) {
6
+ let(:cli) do
8
7
  double("cli")
9
- }
8
+ end
10
9
 
11
- let(:rake) {
10
+ let(:rake) do
12
11
  double("rake")
13
- }
12
+ end
14
13
 
15
- let(:file) {
14
+ let(:file) do
16
15
  double("file")
17
- }
16
+ end
18
17
 
19
- let(:store) {
18
+ let(:store) do
20
19
  double("store")
21
- }
20
+ end
22
21
 
23
- let(:host) {
22
+ let(:host) do
24
23
  double("host")
25
- }
24
+ end
26
25
 
27
- let(:hypervisors) {
26
+ let(:hypervisors) do
28
27
  double("hypervisors")
29
- }
28
+ end
30
29
 
31
- let(:hosts) {
30
+ let(:hosts) do
32
31
  double("hosts")
33
- }
32
+ end
34
33
 
35
- let(:hypervisors_object) {
34
+ let(:hypervisors_object) do
36
35
  double("hypervisors_object")
37
- }
36
+ end
38
37
 
39
- let(:hosts_object) {
38
+ let(:hosts_object) do
40
39
  double("hosts_object")
41
- }
40
+ end
42
41
 
43
- let(:network_manager){
42
+ let(:network_manager) do
44
43
  double("network_manager")
45
- }
44
+ end
46
45
 
47
- let(:save_object){
46
+ let(:save_object) do
48
47
  double("save_object")
49
- }
48
+ end
50
49
 
51
- let(:load_object){
50
+ let(:load_object) do
52
51
  double("load_object")
53
- }
52
+ end
54
53
 
55
- let(:yaml_object){
54
+ let(:yaml_object) do
56
55
  double("yaml_object")
57
- }
56
+ end
58
57
 
59
58
  describe 'execute_subcommand' do
60
59
  it "determines if we should execute the init subcommand" do
@@ -78,13 +77,12 @@ module Beaker
78
77
  end
79
78
  end
80
79
 
81
-
82
80
  describe 'error_with' do
83
81
  it "the exit value should default to 1" do
84
82
  expect(STDOUT).to receive(:puts).with("exiting").once
85
83
  begin
86
84
  subject.error_with("exiting")
87
- rescue SystemExit=>e
85
+ rescue SystemExit => e
88
86
  expect(e.status).to eq(1)
89
87
  end
90
88
  end
@@ -92,8 +90,8 @@ module Beaker
92
90
  it "the exit value should return specified value" do
93
91
  expect(STDOUT).to receive(:puts).with("exiting").once
94
92
  begin
95
- subject.error_with("exiting", {exit_code: 3})
96
- rescue SystemExit=>e
93
+ subject.error_with("exiting", { exit_code: 3 })
94
+ rescue SystemExit => e
97
95
  expect(e.status).to eq(3)
98
96
  end
99
97
  end
@@ -102,8 +100,8 @@ module Beaker
102
100
  expect(STDOUT).to receive(:puts).with("exiting").once
103
101
  expect(STDOUT).to receive(:puts).with("testing").once
104
102
  begin
105
- subject.error_with("exiting", {stack_trace: "testing"})
106
- rescue SystemExit=>e
103
+ subject.error_with("exiting", { stack_trace: "testing" })
104
+ rescue SystemExit => e
107
105
  expect(e.status).to eq(1)
108
106
  end
109
107
  end