beaker 4.40.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) 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 +17 -28
  8. data/Gemfile +12 -7
  9. data/Rakefile +99 -111
  10. data/acceptance/config/acceptance-options.rb +1 -1
  11. data/acceptance/config/base/acceptance-options.rb +2 -2
  12. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  13. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  14. data/acceptance/fixtures/module/Rakefile +1 -1
  15. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  16. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  17. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  18. data/acceptance/lib/helpers/test_helper.rb +6 -5
  19. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  20. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  21. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  40. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  41. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  42. data/acceptance/tests/base/host/file_test.rb +2 -2
  43. data/acceptance/tests/base/host/group_test.rb +0 -1
  44. data/acceptance/tests/base/host/host_test.rb +66 -63
  45. data/acceptance/tests/base/host/packages.rb +1 -2
  46. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  47. data/acceptance/tests/base/host/user_test.rb +0 -1
  48. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  49. data/acceptance/tests/base/test_suite/export.rb +6 -9
  50. data/acceptance/tests/install/from_file.rb +2 -4
  51. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  52. data/acceptance/tests/subcommands/destroy.rb +19 -21
  53. data/acceptance/tests/subcommands/exec.rb +0 -1
  54. data/acceptance/tests/subcommands/init.rb +2 -3
  55. data/acceptance/tests/subcommands/provision.rb +0 -1
  56. data/beaker.gemspec +4 -7
  57. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  58. data/docs/how_to/debug_beaker_tests.md +12 -12
  59. data/docs/how_to/hosts/eos.md +2 -12
  60. data/docs/how_to/install_puppet.md +0 -18
  61. data/docs/how_to/the_beaker_dsl.md +0 -2
  62. data/lib/beaker/cli.rb +59 -68
  63. data/lib/beaker/command.rb +20 -28
  64. data/lib/beaker/command_factory.rb +3 -2
  65. data/lib/beaker/dsl/assertions.rb +6 -18
  66. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  67. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  68. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  69. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  70. data/lib/beaker/dsl/helpers.rb +2 -4
  71. data/lib/beaker/dsl/outcomes.rb +13 -15
  72. data/lib/beaker/dsl/patterns.rb +1 -3
  73. data/lib/beaker/dsl/roles.rb +17 -20
  74. data/lib/beaker/dsl/structure.rb +53 -65
  75. data/lib/beaker/dsl/test_tagging.rb +7 -10
  76. data/lib/beaker/dsl/wrappers.rb +15 -16
  77. data/lib/beaker/dsl.rb +2 -3
  78. data/lib/beaker/host/aix/exec.rb +1 -1
  79. data/lib/beaker/host/aix/file.rb +0 -1
  80. data/lib/beaker/host/aix/group.rb +1 -1
  81. data/lib/beaker/host/aix/user.rb +1 -1
  82. data/lib/beaker/host/aix.rb +3 -4
  83. data/lib/beaker/host/cisco.rb +27 -39
  84. data/lib/beaker/host/eos.rb +4 -30
  85. data/lib/beaker/host/freebsd/exec.rb +1 -1
  86. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  87. data/lib/beaker/host/freebsd.rb +9 -12
  88. data/lib/beaker/host/mac/exec.rb +4 -4
  89. data/lib/beaker/host/mac/group.rb +7 -7
  90. data/lib/beaker/host/mac/pkg.rb +3 -106
  91. data/lib/beaker/host/mac/user.rb +2 -2
  92. data/lib/beaker/host/mac.rb +8 -9
  93. data/lib/beaker/host/pswindows/exec.rb +66 -70
  94. data/lib/beaker/host/pswindows/file.rb +3 -5
  95. data/lib/beaker/host/pswindows/group.rb +3 -3
  96. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  97. data/lib/beaker/host/pswindows/user.rb +3 -3
  98. data/lib/beaker/host/pswindows.rb +4 -3
  99. data/lib/beaker/host/unix/exec.rb +80 -82
  100. data/lib/beaker/host/unix/file.rb +38 -43
  101. data/lib/beaker/host/unix/group.rb +1 -1
  102. data/lib/beaker/host/unix/pkg.rb +154 -417
  103. data/lib/beaker/host/unix/user.rb +2 -2
  104. data/lib/beaker/host/unix.rb +8 -11
  105. data/lib/beaker/host/windows/exec.rb +17 -17
  106. data/lib/beaker/host/windows/file.rb +3 -3
  107. data/lib/beaker/host/windows/group.rb +3 -3
  108. data/lib/beaker/host/windows/pkg.rb +3 -54
  109. data/lib/beaker/host/windows/user.rb +3 -3
  110. data/lib/beaker/host/windows.rb +12 -12
  111. data/lib/beaker/host.rb +76 -133
  112. data/lib/beaker/host_prebuilt_steps.rb +93 -198
  113. data/lib/beaker/hypervisor/noop.rb +2 -4
  114. data/lib/beaker/hypervisor.rb +44 -61
  115. data/lib/beaker/local_connection.rb +2 -4
  116. data/lib/beaker/logger.rb +68 -76
  117. data/lib/beaker/logger_junit.rb +21 -25
  118. data/lib/beaker/network_manager.rb +39 -42
  119. data/lib/beaker/options/command_line_parser.rb +12 -23
  120. data/lib/beaker/options/hosts_file_parser.rb +16 -24
  121. data/lib/beaker/options/options_file_parser.rb +3 -6
  122. data/lib/beaker/options/options_hash.rb +2 -7
  123. data/lib/beaker/options/parser.rb +86 -102
  124. data/lib/beaker/options/presets.rb +114 -123
  125. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  126. data/lib/beaker/options/validator.rb +26 -31
  127. data/lib/beaker/perf.rb +22 -27
  128. data/lib/beaker/platform.rb +38 -46
  129. data/lib/beaker/result.rb +7 -6
  130. data/lib/beaker/shared/error_handler.rb +8 -10
  131. data/lib/beaker/shared/fog_credentials.rb +5 -9
  132. data/lib/beaker/shared/host_manager.rb +36 -41
  133. data/lib/beaker/shared/options_resolver.rb +3 -7
  134. data/lib/beaker/shared/repetition.rb +2 -4
  135. data/lib/beaker/shared/semvar.rb +37 -41
  136. data/lib/beaker/shared/timed.rb +0 -3
  137. data/lib/beaker/shared.rb +1 -1
  138. data/lib/beaker/ssh_connection.rb +38 -47
  139. data/lib/beaker/subcommand.rb +17 -24
  140. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  141. data/lib/beaker/tasks/quick_start.rb +4 -9
  142. data/lib/beaker/tasks/rake_task.rb +25 -27
  143. data/lib/beaker/tasks/test.rb +4 -4
  144. data/lib/beaker/test_case.rb +16 -28
  145. data/lib/beaker/test_suite.rb +35 -39
  146. data/lib/beaker/test_suite_result.rb +45 -47
  147. data/lib/beaker/version.rb +1 -1
  148. data/lib/beaker.rb +6 -7
  149. data/spec/beaker/cli_spec.rb +121 -142
  150. data/spec/beaker/command_spec.rb +55 -59
  151. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  152. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  153. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  154. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  155. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  156. data/spec/beaker/dsl/roles_spec.rb +125 -130
  157. data/spec/beaker/dsl/structure_spec.rb +172 -161
  158. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  159. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  160. data/spec/beaker/host/aix_spec.rb +14 -14
  161. data/spec/beaker/host/cisco_spec.rb +84 -94
  162. data/spec/beaker/host/eos_spec.rb +15 -36
  163. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  164. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  165. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  166. data/spec/beaker/host/mac/group_spec.rb +48 -57
  167. data/spec/beaker/host/mac/user_spec.rb +54 -63
  168. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  169. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  170. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  171. data/spec/beaker/host/pswindows_spec.rb +13 -13
  172. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  173. data/spec/beaker/host/unix/file_spec.rb +66 -73
  174. data/spec/beaker/host/unix/pkg_spec.rb +155 -401
  175. data/spec/beaker/host/unix_spec.rb +11 -207
  176. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  177. data/spec/beaker/host/windows/file_spec.rb +18 -19
  178. data/spec/beaker/host/windows/group_spec.rb +10 -12
  179. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  180. data/spec/beaker/host/windows/user_spec.rb +17 -23
  181. data/spec/beaker/host/windows_spec.rb +39 -39
  182. data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
  183. data/spec/beaker/host_spec.rb +204 -284
  184. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  185. data/spec/beaker/localhost_connection_spec.rb +10 -11
  186. data/spec/beaker/logger_junit_spec.rb +19 -30
  187. data/spec/beaker/logger_spec.rb +153 -136
  188. data/spec/beaker/network_manager_spec.rb +23 -23
  189. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  190. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  191. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  192. data/spec/beaker/options/options_hash_spec.rb +4 -6
  193. data/spec/beaker/options/parser_spec.rb +167 -167
  194. data/spec/beaker/options/presets_spec.rb +7 -9
  195. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  196. data/spec/beaker/options/validator_spec.rb +10 -11
  197. data/spec/beaker/perf_spec.rb +18 -21
  198. data/spec/beaker/platform_spec.rb +25 -36
  199. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  200. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  201. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  202. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  203. data/spec/beaker/shared/repetition_spec.rb +17 -24
  204. data/spec/beaker/shared/semvar_spec.rb +21 -26
  205. data/spec/beaker/ssh_connection_spec.rb +76 -83
  206. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  207. data/spec/beaker/subcommand_spec.rb +75 -77
  208. data/spec/beaker/test_case_spec.rb +25 -50
  209. data/spec/beaker/test_suite_spec.rb +147 -154
  210. data/spec/helpers.rb +48 -53
  211. data/spec/matchers.rb +8 -7
  212. data/spec/mocks.rb +1 -6
  213. data/spec/spec_helper.rb +0 -1
  214. metadata +7 -24
  215. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  216. data/acceptance/tests/base/external_resources_test.rb +0 -31
  217. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  module Beaker
4
4
  SubcommandUtil = Beaker::Subcommands::SubcommandUtil
5
5
  describe Subcommand do
6
- let( :subcommand ) {
6
+ let(:subcommand) do
7
7
  described_class.new
8
- }
8
+ end
9
9
 
10
10
  describe '#initialize' do
11
11
  it 'creates a cli object' do
@@ -32,51 +32,51 @@ module Beaker
32
32
  end
33
33
 
34
34
  context 'ensure that beaker options can be passed through' do
35
+ let(:beaker_options_list) do
36
+ %w[
37
+ options-file
38
+ helper
39
+ load-path
40
+ tests
41
+ pre-suite
42
+ post-suite
43
+ pre-cleanup
44
+ provision
45
+ preserve-hosts
46
+ preserve-state
47
+ root-keys
48
+ keyfile
49
+ timeout
50
+ install
51
+ modules
52
+ quiet
53
+ color
54
+ color-host-output
55
+ log-level
56
+ log-prefix
57
+ dry-run
58
+ fail-mode
59
+ ntp
60
+ repo-proxy
61
+ package-proxy
62
+ validate
63
+ collect-perf-data
64
+ parse-only
65
+ tag
66
+ exclude-tags
67
+ xml-time-order
68
+ debug-errors
69
+ exec_manual_tests
70
+ test-tag-exclude
71
+ test-tag-and
72
+ test-tag-or
73
+ xml
74
+ type
75
+ debug
76
+ ]
77
+ end
35
78
 
36
- let(:beaker_options_list) { [
37
- 'options-file',
38
- 'helper',
39
- 'load-path',
40
- 'tests',
41
- 'pre-suite',
42
- 'post-suite',
43
- 'pre-cleanup',
44
- 'provision',
45
- 'preserve-hosts',
46
- 'preserve-state',
47
- 'root-keys',
48
- 'keyfile',
49
- 'timeout',
50
- 'install',
51
- 'modules',
52
- 'quiet',
53
- 'color',
54
- 'color-host-output',
55
- 'log-level',
56
- 'log-prefix',
57
- 'dry-run',
58
- 'fail-mode',
59
- 'ntp',
60
- 'repo-proxy',
61
- 'add-el-extras',
62
- 'package-proxy',
63
- 'validate',
64
- 'collect-perf-data',
65
- 'parse-only',
66
- 'tag',
67
- 'exclude-tags',
68
- 'xml-time-order',
69
- 'debug-errors',
70
- 'exec_manual_tests',
71
- 'test-tag-exclude',
72
- 'test-tag-and',
73
- 'test-tag-or',
74
- 'xml',
75
- 'type',
76
- 'debug',
77
- ] }
78
-
79
- let( :yaml_store_mock ) { double('yaml_store_mock') }
79
+ let(:yaml_store_mock) { double('yaml_store_mock') }
80
80
 
81
81
  it 'does not error with valid beaker options' do
82
82
  beaker_options_list.each do |option|
@@ -91,7 +91,7 @@ module Beaker
91
91
  expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
92
92
  expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
93
93
 
94
- expect {described_class.start(['init', '--hosts', 'centos', "--#{option}"])}.not_to output(/ERROR/).to_stderr
94
+ expect { described_class.start(['init', '--hosts', 'centos', "--#{option}"]) }.not_to output(/ERROR/).to_stderr
95
95
  end
96
96
  end
97
97
 
@@ -102,14 +102,14 @@ module Beaker
102
102
  expect(File).not_to receive(:open)
103
103
  expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
104
104
  expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
105
- expect {described_class.start(['init', '--hosts', 'centos', '--bad-option'])}.to output(/ERROR/).to_stderr
105
+ expect { described_class.start(['init', '--hosts', 'centos', '--bad-option']) }.to output(/ERROR/).to_stderr
106
106
  end
107
107
  end
108
108
 
109
109
  describe '#init' do
110
- let( :cli ) { subcommand.cli }
111
- let( :mock_options ) { {:timestamp => 'noon', :other_key => 'cordite'}}
112
- let( :yaml_store_mock ) { double('yaml_store_mock') }
110
+ let(:cli) { subcommand.cli }
111
+ let(:mock_options) { { :timestamp => 'noon', :other_key => 'cordite' } }
112
+ let(:yaml_store_mock) { double('yaml_store_mock') }
113
113
 
114
114
  before do
115
115
  allow(cli).to receive(:parse_options)
@@ -126,21 +126,21 @@ module Beaker
126
126
  end
127
127
 
128
128
  it 'requires hosts flag' do
129
- expect{subcommand.init}.to raise_error(NotImplementedError)
129
+ expect { subcommand.init }.to raise_error(NotImplementedError)
130
130
  end
131
131
  end
132
132
 
133
133
  describe '#provision' do
134
- let( :cli ) { subcommand.cli }
135
- let( :yaml_store_mock ) { double('yaml_store_mock') }
136
- let( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
137
- let( :cleaned_hosts ) {double()}
138
- let( :yielded_host_hash ) {double()}
139
- let( :yielded_host_name) {double()}
140
- let( :network_manager) {double('network_manager')}
141
- let( :hosts) {double('hosts')}
142
- let( :hypervisors) {double('hypervisors')}
143
- let(:options) {double('options')}
134
+ let(:cli) { subcommand.cli }
135
+ let(:yaml_store_mock) { double('yaml_store_mock') }
136
+ let(:host_hash) { { 'mynode.net' => { :name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64') } } }
137
+ let(:cleaned_hosts) { double }
138
+ let(:yielded_host_hash) { double }
139
+ let(:yielded_host_name) { double }
140
+ let(:network_manager) { double('network_manager') }
141
+ let(:hosts) { double('hosts') }
142
+ let(:hypervisors) { double('hypervisors') }
143
+ let(:options) { double('options') }
144
144
 
145
145
  it 'provisions the host and saves the host info' do
146
146
  expect(YAML::Store).to receive(:new).with(SubcommandUtil::SUBCOMMAND_STATE).and_return(yaml_store_mock)
@@ -168,8 +168,8 @@ module Beaker
168
168
  end
169
169
 
170
170
  it 'does not allow hosts to be passed' do
171
- subcommand.options = {:hosts => "myhost"}
172
- expect{subcommand.provision()}.to raise_error(NotImplementedError)
171
+ subcommand.options = { :hosts => "myhost" }
172
+ expect { subcommand.provision }.to raise_error(NotImplementedError)
173
173
  end
174
174
  end
175
175
 
@@ -180,15 +180,15 @@ module Beaker
180
180
  allow(subcommand.cli).to receive(:execute!)
181
181
  end
182
182
 
183
- let( :cleaned_hosts ) {double()}
184
- let( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
185
- let( :yaml_store_mock ) { double('yaml_store_mock') }
183
+ let(:cleaned_hosts) { double }
184
+ let(:host_hash) { { 'mynode.net' => { :name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64') } } }
185
+ let(:yaml_store_mock) { double('yaml_store_mock') }
186
186
 
187
187
  it 'calls execute! when no resource is given' do
188
188
  expect_any_instance_of(Pathname).not_to receive(:directory?)
189
189
  expect_any_instance_of(Pathname).not_to receive(:exist?)
190
190
  expect(subcommand.cli).to receive(:execute!).once
191
- expect{subcommand.exec}.not_to raise_error
191
+ expect { subcommand.exec }.not_to raise_error
192
192
  end
193
193
 
194
194
  it 'allows hard coded suite names to be specified' do
@@ -205,7 +205,7 @@ module Beaker
205
205
 
206
206
  it 'errors when a resource is neither a valid file resource or suite name' do
207
207
  allow_any_instance_of(Pathname).to receive(:exist?).and_return(false)
208
- expect{subcommand.exec('blahblahblah')}.to raise_error(ArgumentError)
208
+ expect { subcommand.exec('blahblahblah') }.to raise_error(ArgumentError)
209
209
  end
210
210
 
211
211
  it 'accepts a tests directory, clearing all other suites' do
@@ -249,13 +249,11 @@ module Beaker
249
249
  it 'rejects comma-separated file and suite name' do
250
250
  allow_any_instance_of(Pathname).to receive(:exist?).and_return(false)
251
251
 
252
- expect {
252
+ expect do
253
253
  subcommand.exec('pre-suite,tests/whoops')
254
- }.to raise_error(ArgumentError, %r{Unable to parse pre-suite,tests/whoops})
254
+ end.to raise_error(ArgumentError, %r{Unable to parse pre-suite,tests/whoops})
255
255
  end
256
256
 
257
-
258
-
259
257
  it 'updates the subcommand_options file with new host info if `preserve-state` is set' do
260
258
  allow(yaml_store_mock).to receive(:[]).and_return(false)
261
259
  allow(subcommand).to receive(:options).and_return('preserve-state' => true)
@@ -280,10 +278,10 @@ module Beaker
280
278
  end
281
279
 
282
280
  context 'destroy' do
283
- let( :cli ) { subcommand.cli }
284
- let( :mock_options ) { {:timestamp => 'noon', :other_key => 'cordite'}}
285
- let( :yaml_store_mock ) { double('yaml_store_mock') }
286
- let( :network_manager) {double('network_manager')}
281
+ let(:cli) { subcommand.cli }
282
+ let(:mock_options) { { :timestamp => 'noon', :other_key => 'cordite' } }
283
+ let(:yaml_store_mock) { double('yaml_store_mock') }
284
+ let(:network_manager) { double('network_manager') }
287
285
 
288
286
  it 'calls destroy and updates the yaml store' do
289
287
  allow(cli).to receive(:parse_options)
@@ -9,116 +9,96 @@ module Beaker
9
9
  context 'run_test' do
10
10
  it 'defaults to test_status :pass on success' do
11
11
  path = 'test.rb'
12
- File.open(path, 'w') do |f|
13
- f.write ""
14
- end
12
+ File.write(path, "")
15
13
  @path = path
16
- expect( testcase ).not_to receive( :log_and_fail_test )
14
+ expect(testcase).not_to receive(:log_and_fail_test)
17
15
  testcase.run_test
18
16
  expect(testcase.test_status).to be === :pass
19
17
  end
20
18
 
21
19
  it 'updates test_status to :skip on SkipTest' do
22
20
  path = 'test.rb'
23
- File.open(path, 'w') do |f|
24
- f.write "raise SkipTest"
25
- end
21
+ File.write(path, "raise SkipTest")
26
22
  @path = path
27
- expect( testcase ).not_to receive( :log_and_fail_test )
23
+ expect(testcase).not_to receive(:log_and_fail_test)
28
24
  testcase.run_test
29
25
  expect(testcase.test_status).to be === :skip
30
26
  end
31
27
 
32
28
  it 'updates test_status to :pending on PendingTest' do
33
29
  path = 'test.rb'
34
- File.open(path, 'w') do |f|
35
- f.write "raise PendingTest"
36
- end
30
+ File.write(path, "raise PendingTest")
37
31
  @path = path
38
- expect( testcase ).not_to receive( :log_and_fail_test )
32
+ expect(testcase).not_to receive(:log_and_fail_test)
39
33
  testcase.run_test
40
34
  expect(testcase.test_status).to be === :pending
41
35
  end
42
36
 
43
37
  it 'updates test_status to :fail on FailTest' do
44
38
  path = 'test.rb'
45
- File.open(path, 'w') do |f|
46
- f.write "raise FailTest"
47
- end
39
+ File.write(path, "raise FailTest")
48
40
  @path = path
49
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Beaker::DSL::FailTest), :fail).and_call_original
41
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Beaker::DSL::FailTest), :fail).and_call_original
50
42
  testcase.run_test
51
43
  expect(testcase.test_status).to be === :fail
52
44
  end
53
45
 
54
46
  it 'correctly handles RuntimeError' do
55
47
  path = 'test.rb'
56
- File.open(path, 'w') do |f|
57
- f.write "raise RuntimeError"
58
- end
48
+ File.write(path, "raise RuntimeError")
59
49
  @path = path
60
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(RuntimeError))
50
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(RuntimeError))
61
51
  testcase.run_test
62
52
  end
63
53
 
64
54
  it 'correctly handles ScriptError' do
65
55
  path = 'test.rb'
66
- File.open(path, 'w') do |f|
67
- f.write "raise ScriptError"
68
- end
56
+ File.write(path, "raise ScriptError")
69
57
  @path = path
70
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(ScriptError))
58
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(ScriptError))
71
59
  testcase.run_test
72
60
  end
73
61
 
74
62
  it 'correctly handles Timeout::Error' do
75
63
  path = 'test.rb'
76
- File.open(path, 'w') do |f|
77
- f.write "raise Timeout::Error"
78
- end
64
+ File.write(path, "raise Timeout::Error")
79
65
  @path = path
80
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Timeout::Error))
66
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Timeout::Error))
81
67
  testcase.run_test
82
68
  end
83
69
 
84
70
  it 'correctly handles CommandFailure' do
85
71
  path = 'test.rb'
86
- File.open(path, 'w') do |f|
87
- f.write "raise Host::CommandFailure"
88
- end
72
+ File.write(path, "raise Host::CommandFailure")
89
73
  @path = path
90
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Host::CommandFailure))
74
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Host::CommandFailure))
91
75
  testcase.run_test
92
76
  end
93
77
 
94
78
  it 'records a test failure if an assertion fails in a teardown block' do
95
79
  path = 'test.rb'
96
- File.open(path, 'w') do |f|
97
- f.write <<-EOF
80
+ File.write(path, <<-EOF)
98
81
  teardown do
99
82
  assert_equal(1, 2, 'Oh noes!')
100
83
  end
101
- EOF
102
- end
84
+ EOF
103
85
  @path = path
104
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
86
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
105
87
  testcase.run_test
106
88
  expect(testcase.test_status).to eq(:error)
107
89
  end
108
90
 
109
91
  it 'does not overwrite a test failure if an assertion also happens in a teardown block' do
110
92
  path = 'test.rb'
111
- File.open(path, 'w') do |f|
112
- f.write <<-EOF
93
+ File.write(path, <<-EOF)
113
94
  teardown do
114
95
  assert_equal(1, 2, 'Oh noes!')
115
96
  end
116
97
  assert_equal(true, false, 'failed test')
117
- EOF
118
- end
98
+ EOF
119
99
  @path = path
120
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :fail).and_call_original
121
- expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
100
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :fail).and_call_original
101
+ expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
122
102
  testcase.run_test
123
103
  expect(testcase.test_status).to eq(:fail)
124
104
  end
@@ -128,9 +108,7 @@ module Beaker
128
108
  it 'sets the filename correctly from the path' do
129
109
  answer = 'jacket'
130
110
  path = "#{answer}.rb"
131
- File.open(path, 'w') do |f|
132
- f.write ""
133
- end
111
+ File.write(path, "")
134
112
  @path = path
135
113
  testcase.run_test
136
114
  metadata = testcase.instance_variable_get(:@metadata)
@@ -139,9 +117,7 @@ module Beaker
139
117
 
140
118
  it 'resets the step name' do
141
119
  path = 'test.rb'
142
- File.open(path, 'w') do |f|
143
- f.write ""
144
- end
120
+ File.write(path, "")
145
121
  @path = path
146
122
  # we have to create a TestCase by hand, so that we can set old
147
123
  tc = described_class.new({}, logger, {}, path)
@@ -153,6 +129,5 @@ module Beaker
153
129
  expect(metadata[:step][:name]).to be_nil
154
130
  end
155
131
  end
156
-
157
132
  end
158
133
  end