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
@@ -13,90 +13,90 @@ describe ClassMixedWithDSLStructure do
13
13
  let(:metadata) { @metadata ||= {} }
14
14
 
15
15
  before do
16
- allow( subject ).to receive(:metadata).and_return(metadata)
16
+ allow(subject).to receive(:metadata).and_return(metadata)
17
17
  end
18
18
 
19
19
  describe '#step' do
20
20
  it 'requires a name' do
21
- expect { subject.step do; end }.to raise_error ArgumentError
21
+ expect { subject.step { ; } }.to raise_error ArgumentError
22
22
  end
23
23
 
24
24
  it 'notifies the logger' do
25
- allow( subject ).to receive( :set_current_step_name )
26
- expect( subject ).to receive( :logger ).and_return( logger )
27
- expect( logger ).to receive( :notify )
25
+ allow(subject).to receive(:set_current_step_name)
26
+ expect(subject).to receive(:logger).and_return(logger)
27
+ expect(logger).to receive(:notify)
28
28
  subject.step 'blah'
29
29
  end
30
30
 
31
31
  it 'yields if a block is given' do
32
- expect( subject ).to receive( :logger ).and_return( logger ).twice
33
- allow( subject ).to receive( :set_current_step_name )
34
- allow( logger ).to receive(:with_indent).and_yield
35
- expect( logger ).to receive( :notify )
36
- expect( subject ).to receive( :foo )
32
+ expect(subject).to receive(:logger).and_return(logger).twice
33
+ allow(subject).to receive(:set_current_step_name)
34
+ allow(logger).to receive(:with_indent).and_yield
35
+ expect(logger).to receive(:notify)
36
+ expect(subject).to receive(:foo)
37
37
  subject.step 'blah' do
38
38
  subject.foo
39
39
  end
40
40
  end
41
41
 
42
42
  it 'sets the metadata' do
43
- allow( subject ).to receive( :logger ).and_return( logger )
44
- allow( logger ).to receive( :notify )
43
+ allow(subject).to receive(:logger).and_return(logger)
44
+ allow(logger).to receive(:notify)
45
45
  step_name = 'pierceBrosnanTests'
46
46
  subject.step step_name
47
- expect( metadata[:step][:name] ).to be === step_name
47
+ expect(metadata[:step][:name]).to be === step_name
48
48
  end
49
49
  end
50
50
 
51
51
  describe '#manual_step' do
52
52
  context 'without exec manual test option' do
53
- let( :options ) { {} }
53
+ let(:options) { {} }
54
54
 
55
55
  it 'throws an error' do
56
- expect( Readline ).not_to receive( :readline )
56
+ expect(Readline).not_to receive(:readline)
57
57
  expect { subject.manual_step 'blah' do; end }.to raise_error StandardError
58
58
  end
59
59
  end
60
60
 
61
61
  context 'with exec manual test option' do
62
- let( :options ) { {exec_manual_tests: nil} }
62
+ let(:options) { { exec_manual_tests: nil } }
63
63
 
64
64
  it 'requires a name' do
65
- expect { subject.manual_step do; end }.to raise_error ArgumentError
65
+ expect { subject.manual_step { ; } }.to raise_error ArgumentError
66
66
  end
67
67
 
68
68
  it 'notifies the logger' do
69
69
  subject.instance_variable_set(:@options, options)
70
- allow( subject ).to receive( :set_current_step_name )
71
- expect( subject ).to receive( :logger ).and_return( logger )
72
- expect( logger ).to receive( :notify )
73
- allow( Readline ).to receive( :readline ).and_return( 'Y')
70
+ allow(subject).to receive(:set_current_step_name)
71
+ expect(subject).to receive(:logger).and_return(logger)
72
+ expect(logger).to receive(:notify)
73
+ allow(Readline).to receive(:readline).and_return('Y')
74
74
  subject.manual_step 'blah'
75
75
  end
76
76
  end
77
77
 
78
78
  context 'with exec manual test option set to true' do
79
- let( :options ) { {exec_manual_tests: true} }
79
+ let(:options) { { exec_manual_tests: true } }
80
80
 
81
81
  it 'requires a name' do
82
- expect { subject.manual_step do; end }.to raise_error ArgumentError
82
+ expect { subject.manual_step { ; } }.to raise_error ArgumentError
83
83
  end
84
84
 
85
85
  it 'pass when user enters Y' do
86
86
  subject.instance_variable_set(:@options, options)
87
- allow( subject ).to receive( :set_current_step_name )
88
- allow( subject ).to receive( :logger ).and_return( logger )
89
- allow( logger ).to receive( :notify )
90
- expect( Readline ).to receive( :readline ).and_return( 'Y')
87
+ allow(subject).to receive(:set_current_step_name)
88
+ allow(subject).to receive(:logger).and_return(logger)
89
+ allow(logger).to receive(:notify)
90
+ expect(Readline).to receive(:readline).and_return('Y')
91
91
  subject.manual_step 'blahblah'
92
92
  end
93
93
 
94
94
  it 'fails when user enters n and uses default error when no message is entered' do
95
95
  subject.instance_variable_set(:@options, options)
96
- allow( subject ).to receive( :set_current_step_name )
97
- allow( subject ).to receive( :logger ).and_return( logger )
98
- allow( logger ).to receive( :notify )
99
- expect( Readline ).to receive( :readline ).and_return('n', 'step failed')
96
+ allow(subject).to receive(:set_current_step_name)
97
+ allow(subject).to receive(:logger).and_return(logger)
98
+ allow(logger).to receive(:notify)
99
+ expect(Readline).to receive(:readline).and_return('n', 'step failed')
100
100
  expect { subject.manual_step 'blah two' do; end }.to raise_error(Beaker::DSL::FailTest, 'step failed')
101
101
  end
102
102
  end
@@ -104,41 +104,41 @@ describe ClassMixedWithDSLStructure do
104
104
 
105
105
  describe '#manual_test' do
106
106
  context 'without exec manual test option' do
107
- let( :options ) { {} }
107
+ let(:options) { {} }
108
108
 
109
109
  it 'requires a name' do
110
- expect { subject.manual_test do; end }.to raise_error ArgumentError
110
+ expect { subject.manual_test { ; } }.to raise_error ArgumentError
111
111
  end
112
112
 
113
113
  it 'raises a skip test' do
114
114
  subject.instance_variable_set(:@options, options)
115
- allow( subject ).to receive( :logger ).and_return( logger )
116
- allow( logger ).to receive( :notify )
115
+ allow(subject).to receive(:logger).and_return(logger)
116
+ allow(logger).to receive(:notify)
117
117
  test_name = 'random test name'
118
118
  expect { subject.manual_test test_name do; end }.to raise_error Beaker::DSL::SkipTest
119
119
  end
120
120
  end
121
121
 
122
122
  context 'with exec manual test option' do
123
- let( :options ) { {exec_manual_tests: true} }
123
+ let(:options) { { exec_manual_tests: true } }
124
124
 
125
125
  it 'requires a name' do
126
- expect { subject.manual_test do; end }.to raise_error ArgumentError
126
+ expect { subject.manual_test { ; } }.to raise_error ArgumentError
127
127
  end
128
128
 
129
129
  it 'notifies the logger' do
130
130
  subject.instance_variable_set(:@options, options)
131
- expect( subject ).to receive( :logger ).and_return( logger )
132
- expect( logger ).to receive( :notify )
131
+ expect(subject).to receive(:logger).and_return(logger)
132
+ expect(logger).to receive(:notify)
133
133
  subject.manual_test 'blah blah'
134
134
  end
135
135
 
136
136
  it 'yields if a block is given' do
137
137
  subject.instance_variable_set(:@options, options)
138
- expect( subject ).to receive( :logger ).and_return( logger ).twice
139
- expect( logger ).to receive( :notify )
140
- allow( logger ).to receive(:with_indent).and_yield
141
- expect( subject ).to receive( :foo )
138
+ expect(subject).to receive(:logger).and_return(logger).twice
139
+ expect(logger).to receive(:notify)
140
+ allow(logger).to receive(:with_indent).and_yield
141
+ expect(subject).to receive(:foo)
142
142
  subject.manual_test 'blah' do
143
143
  subject.foo
144
144
  end
@@ -146,43 +146,42 @@ describe ClassMixedWithDSLStructure do
146
146
 
147
147
  it 'sets the metadata' do
148
148
  subject.instance_variable_set(:@options, options)
149
- allow( subject ).to receive( :logger ).and_return( logger )
150
- allow( logger ).to receive( :notify )
149
+ allow(subject).to receive(:logger).and_return(logger)
150
+ allow(logger).to receive(:notify)
151
151
  test_name = 'test is setting metadata yay!'
152
152
  subject.manual_test test_name
153
- expect( metadata[:case][:name] ).to be === test_name
153
+ expect(metadata[:case][:name]).to be === test_name
154
154
  end
155
155
  end
156
156
  end
157
157
 
158
158
  describe '#test_name' do
159
-
160
159
  it 'requires a name' do
161
- expect { subject.test_name do; end }.to raise_error ArgumentError
160
+ expect { subject.test_name { ; } }.to raise_error ArgumentError
162
161
  end
163
162
 
164
163
  it 'notifies the logger' do
165
- expect( subject ).to receive( :logger ).and_return( logger )
166
- expect( logger ).to receive( :notify )
164
+ expect(subject).to receive(:logger).and_return(logger)
165
+ expect(logger).to receive(:notify)
167
166
  subject.test_name 'blah'
168
167
  end
169
168
 
170
169
  it 'yields if a block is given' do
171
- expect( subject ).to receive( :logger ).and_return( logger ).twice
172
- expect( logger ).to receive( :notify )
173
- allow( logger ).to receive(:with_indent).and_yield
174
- expect( subject ).to receive( :foo )
170
+ expect(subject).to receive(:logger).and_return(logger).twice
171
+ expect(logger).to receive(:notify)
172
+ allow(logger).to receive(:with_indent).and_yield
173
+ expect(subject).to receive(:foo)
175
174
  subject.test_name 'blah' do
176
175
  subject.foo
177
176
  end
178
177
  end
179
178
 
180
179
  it 'sets the metadata' do
181
- allow( subject ).to receive( :logger ).and_return( logger )
182
- allow( logger ).to receive( :notify )
180
+ allow(subject).to receive(:logger).and_return(logger)
181
+ allow(logger).to receive(:notify)
183
182
  test_name = '15-05-08\'s weather is beautiful'
184
183
  subject.test_name test_name
185
- expect( metadata[:case][:name] ).to be === test_name
184
+ expect(metadata[:case][:name]).to be === test_name
186
185
  end
187
186
  end
188
187
 
@@ -190,161 +189,174 @@ describe ClassMixedWithDSLStructure do
190
189
  it 'append a block to the @teardown var' do
191
190
  teardown_array = double
192
191
  subject.instance_variable_set :@teardown_procs, teardown_array
193
- block = lambda { 'blah' }
194
- expect( teardown_array ).to receive( :<< ).with( block )
192
+ block = -> { 'blah' }
193
+ expect(teardown_array).to receive(:<<).with(block)
195
194
  subject.teardown(&block)
196
195
  end
197
196
  end
198
197
 
199
198
  describe '#expect_failure' do
200
- it 'passes when a Minitest assertion is raised' do
201
- expect( subject ).to receive( :logger ).and_return( logger )
202
- expect( logger ).to receive( :notify )
199
+ it 'passes when a MiniTest assertion is raised' do
200
+ expect(subject).to receive(:logger).and_return(logger)
201
+ expect(logger).to receive(:notify)
203
202
  # We changed this lambda to use the simplest assert possible; using assert_equal
204
- # caused an error in Minitest 5.9.0 trying to write to the file system.
205
- block = lambda { assert(false, 'this assertion should be caught') }
206
- expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
203
+ # caused an error in minitest 5.9.0 trying to write to the file system.
204
+ block = -> { assert(false, 'this assertion should be caught') }
205
+ expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
207
206
  end
208
207
 
209
208
  it 'passes when a Beaker assertion is raised' do
210
- expect( subject ).to receive( :logger ).and_return( logger )
211
- expect( logger ).to receive( :notify )
212
- block = lambda { assert_no_match('1', '1', '1 and 1 should not match') }
213
- expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
209
+ expect(subject).to receive(:logger).and_return(logger)
210
+ expect(logger).to receive(:notify)
211
+ block = -> { refute_match('1', '1', '1 and 1 should not match') }
212
+ expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
214
213
  end
215
214
 
216
- it 'fails when a non-Beaker, non-Minitest assertion is raised' do
217
- block = lambda { raise 'not a Beaker or Minitest error' }
218
- expect{ subject.expect_failure 'this has a non-Beaker, non-Minitest exception', &block }.to raise_error(RuntimeError, /not a Beaker or Minitest error/)
215
+ it 'fails when a non-Beaker, non-MiniTest assertion is raised' do
216
+ block = -> { raise 'not a Beaker or MiniTest error' }
217
+ expect { subject.expect_failure 'this has a non-Beaker, non-MiniTest exception', &block }.to raise_error(RuntimeError, /not a Beaker or MiniTest error/)
219
218
  end
220
219
 
221
220
  it 'fails when no assertion is raised' do
222
- block = lambda { assert_equal('1', '1', '1 should equal 1') }
223
- expect{ subject.expect_failure 'this has no failure', &block }.to raise_error(RuntimeError, /An assertion was expected to fail, but passed/)
221
+ block = -> { expect('1').to(eq('1'), '1 should equal 1') }
222
+ expect { subject.expect_failure 'this has no failure', &block }.to raise_error(RuntimeError, /An assertion was expected to fail, but passed/)
224
223
  end
225
224
  end
226
225
 
227
- describe 'confine' do
226
+ describe '#confine' do
228
227
  let(:logger) { double.as_null_object }
229
228
 
230
229
  before do
231
- allow( subject ).to receive( :logger ).and_return( logger )
230
+ allow(subject).to receive(:logger).and_return(logger)
232
231
  end
233
232
 
234
233
  it ':to - skips the test if there are no applicable hosts' do
235
- allow( subject ).to receive( :hosts ).and_return( [] )
236
- allow( subject ).to receive( :hosts= )
237
- expect( logger ).to receive( :warn )
238
- expect( subject ).to receive( :skip_test ).with( 'No suitable hosts found with {}' )
239
- subject.confine( :to, {} )
234
+ allow(subject).to receive(:hosts).and_return([])
235
+ allow(subject).to receive(:hosts=)
236
+ expect(logger).to receive(:warn)
237
+ expect(subject).to receive(:skip_test).with('No suitable hosts found with {}')
238
+ subject.confine(:to, {})
240
239
  end
241
240
 
242
241
  it ':except - skips the test if there are no applicable hosts' do
243
- allow( subject ).to receive( :hosts ).and_return( [] )
244
- allow( subject ).to receive( :hosts= )
245
- expect( logger ).to receive( :warn )
246
- expect( subject ).to receive( :skip_test ).with( 'No suitable hosts found without {}' )
247
- subject.confine( :except, {} )
242
+ allow(subject).to receive(:hosts).and_return([])
243
+ allow(subject).to receive(:hosts=)
244
+ expect(logger).to receive(:warn)
245
+ expect(subject).to receive(:skip_test).with('No suitable hosts found without {}')
246
+ subject.confine(:except, {})
248
247
  end
249
248
 
250
249
  it ':to - uses a provided host subset when no criteria is provided' do
251
- subset = ['host1', 'host2']
250
+ subset = %w[host1 host2]
252
251
  hosts = subset.dup << 'host3'
253
- allow( subject ).to receive( :hosts ).and_return(hosts).twice
254
- expect( subject ).to receive( :hosts= ).with( subset )
252
+ allow(subject).to receive(:hosts).and_return(hosts).twice
253
+ expect(subject).to receive(:hosts=).with(subset)
255
254
  subject.confine :to, {}, subset
256
255
  end
257
256
 
258
257
  it ':except - excludes provided host subset when no criteria is provided' do
259
- subset = ['host1', 'host2']
258
+ subset = %w[host1 host2]
260
259
  hosts = subset.dup << 'host3'
261
- allow( subject ).to receive( :hosts ).and_return(hosts).twice
262
- expect( subject ).to receive( :hosts= ).with( hosts - subset )
260
+ allow(subject).to receive(:hosts).and_return(hosts).twice
261
+ expect(subject).to receive(:hosts=).with(hosts - subset)
263
262
  subject.confine :except, {}, subset
264
263
  end
265
264
 
266
265
  it 'raises when given mode is not :to or :except' do
267
- hosts = ['host1', 'host2']
268
- allow( subject ).to receive( :hosts ).and_return(hosts)
269
- allow( subject ).to receive( :hosts= )
266
+ hosts = %w[host1 host2]
267
+ allow(subject).to receive(:hosts).and_return(hosts)
268
+ allow(subject).to receive(:hosts=)
270
269
 
271
- expect {
272
- subject.confine( :regardless, {:thing => 'value'} )
273
- }.to raise_error( 'Unknown option regardless' )
270
+ expect do
271
+ subject.confine(:regardless, { :thing => 'value' })
272
+ end.to raise_error('Unknown option regardless')
274
273
  end
275
274
 
276
275
  it 'rejects hosts that do not meet simple hash criteria' do
277
- hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'} ]
276
+ hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
278
277
 
279
- expect( subject ).to receive( :hosts ).and_return( hosts ).twice
280
- expect( subject ).to receive( :hosts= ).
281
- with( [ {'thing' => 'foo'} ] )
278
+ expect(subject).to receive(:hosts).and_return(hosts).twice
279
+ expect(subject).to receive(:hosts=)
280
+ .with([{ 'thing' => 'foo' }])
282
281
 
283
282
  subject.confine :to, :thing => 'foo'
284
283
  end
285
284
 
286
285
  it 'rejects hosts that match a list of criteria' do
287
- hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'}, {'thing' => 'baz'} ]
286
+ hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
288
287
 
289
- expect( subject ).to receive( :hosts ).and_return( hosts ).twice
290
- expect( subject ).to receive( :hosts= ).
291
- with( [ {'thing' => 'bar'} ] )
288
+ expect(subject).to receive(:hosts).and_return(hosts).twice
289
+ expect(subject).to receive(:hosts=)
290
+ .with([{ 'thing' => 'bar' }])
292
291
 
293
- subject.confine :except, :thing => ['foo', 'baz']
292
+ subject.confine :except, :thing => %w[foo baz]
294
293
  end
295
294
 
296
295
  it 'rejects hosts when a passed block returns true' do
297
- host1 = {'platform' => 'solaris'}
298
- host2 = {'platform' => 'solaris'}
299
- host3 = {'platform' => 'windows'}
296
+ host1 = { 'platform' => 'solaris' }
297
+ host2 = { 'platform' => 'solaris' }
298
+ host3 = { 'platform' => 'windows' }
300
299
  ret1 = (Struct.new('Result1', :stdout)).new(':global')
301
300
  ret2 = (Struct.new('Result2', :stdout)).new('a_zone')
302
- hosts = [ host1, host2, host3 ]
301
+ hosts = [host1, host2, host3]
303
302
 
304
- expect( subject ).to receive( :hosts ).and_return( hosts ).twice
305
- expect( subject ).to receive( :on ).
306
- with( host1, '/sbin/zonename' ).
307
- and_return( ret1 )
308
- expect( subject ).to receive( :on ).
309
- with( host1, '/sbin/zonename' ).
310
- and_return( ret2 )
303
+ expect(subject).to receive(:hosts).and_return(hosts).twice
304
+ expect(subject).to receive(:on)
305
+ .with(host1, '/sbin/zonename')
306
+ .and_return(ret1)
307
+ expect(subject).to receive(:on)
308
+ .with(host1, '/sbin/zonename')
309
+ .and_return(ret2)
311
310
 
312
- expect( subject ).to receive( :hosts= ).with( [ host1 ] )
311
+ expect(subject).to receive(:hosts=).with([host1])
313
312
 
314
313
  subject.confine :to, :platform => 'solaris' do |host|
315
- subject.on( host, '/sbin/zonename' ).stdout.include?(':global')
314
+ subject.on(host, '/sbin/zonename').stdout.include?(':global')
316
315
  end
317
316
  end
318
317
 
319
318
  it 'doesn\'t corrupt the global hosts hash when confining from a subset of hosts' do
320
- host1 = {'platform' => 'solaris', :roles => ['master']}
321
- host2 = {'platform' => 'solaris', :roles => ['agent']}
322
- host3 = {'platform' => 'windows', :roles => ['agent']}
323
- hosts = [ host1, host2, host3 ]
324
- agents = [ host2, host3 ]
319
+ host1 = { 'platform' => 'solaris', :roles => ['master'] }
320
+ host2 = { 'platform' => 'solaris', :roles => ['agent'] }
321
+ host3 = { 'platform' => 'windows', :roles => ['agent'] }
322
+ hosts = [host1, host2, host3]
323
+ agents = [host2, host3]
325
324
 
326
- expect( subject ).to receive( :hosts ).and_return( hosts )
327
- expect( subject ).to receive( :hosts= ).with( [ host2, host1 ] )
328
- confined_hosts = subject.confine :except, {:platform => 'windows'}, agents
329
- expect( confined_hosts ).to be === [ host2, host1 ]
325
+ expect(subject).to receive(:hosts).and_return(hosts)
326
+ expect(subject).to receive(:hosts=).with([host2, host1])
327
+ confined_hosts = subject.confine :except, { :platform => 'windows' }, agents
328
+ expect(confined_hosts).to be === [host2, host1]
330
329
  end
331
330
 
332
331
  it 'can apply multiple confines correctly' do
333
- host1 = {'platform' => 'solaris', :roles => ['master']}
334
- host2 = {'platform' => 'solaris', :roles => ['agent']}
335
- host3 = {'platform' => 'windows', :roles => ['agent']}
336
- host4 = {'platform' => 'fedora', :roles => ['agent']}
337
- host5 = {'platform' => 'fedora', :roles => ['agent']}
338
- hosts = [ host1, host2, host3, host4, host5 ]
339
- agents = [ host2, host3, host4, host5 ]
340
-
341
- expect( subject ).to receive( :hosts ).and_return( hosts ).exactly(3).times
342
- expect( subject ).to receive( :hosts= ).with( [ host1, host2, host4, host5 ] )
343
- hosts = subject.confine :except, {:platform => 'windows'}
344
- expect( hosts ).to be === [ host1, host2, host4, host5 ]
345
- expect( subject ).to receive( :hosts= ).with( [ host4, host5, host1 ] )
346
- hosts = subject.confine :to, {:platform => 'fedora'}, agents
347
- expect( hosts ).to be === [ host4, host5, host1 ]
332
+ host1 = { 'platform' => 'solaris', :roles => ['master'] }
333
+ host2 = { 'platform' => 'solaris', :roles => ['agent'] }
334
+ host3 = { 'platform' => 'windows', :roles => ['agent'] }
335
+ host4 = { 'platform' => 'fedora', :roles => ['agent'] }
336
+ host5 = { 'platform' => 'fedora', :roles => ['agent'] }
337
+ hosts = [host1, host2, host3, host4, host5]
338
+ agents = [host2, host3, host4, host5]
339
+
340
+ expect(subject).to receive(:hosts).and_return(hosts).exactly(3).times
341
+ expect(subject).to receive(:hosts=).with([host1, host2, host4, host5])
342
+ hosts = subject.confine :except, { :platform => 'windows' }
343
+ expect(hosts).to be === [host1, host2, host4, host5]
344
+ expect(subject).to receive(:hosts=).with([host4, host5, host1])
345
+ hosts = subject.confine :to, { :platform => 'fedora' }, agents
346
+ expect(hosts).to be === [host4, host5, host1]
347
+ end
348
+
349
+ it 'can apply confine with multiple arguments' do
350
+ host1 = { 'platform' => 'solaris', 'hypervisor' => 'vmpooler' }
351
+ host2 = { 'platform' => 'windows', 'hypervisor' => 'vmpooler' }
352
+ host3 = { 'platform' => 'fedora', 'hypervisor' => 'vmpooler' }
353
+ host4 = { 'platform' => 'fedora', 'hypervisor' => 'docker' }
354
+ hosts = [host1, host2, host3, host4]
355
+
356
+ expect(subject).to receive(:hosts).and_return(hosts).twice
357
+ expect(subject).to receive(:hosts=).with([host1, host2, host3])
358
+ result = subject.confine :except, { :platform => 'fedora', :hypervisor => 'docker' }
359
+ expect(result).to eq([host1, host2, host3])
348
360
  end
349
361
  end
350
362
 
@@ -352,40 +364,39 @@ describe ClassMixedWithDSLStructure do
352
364
  let(:logger) { double.as_null_object }
353
365
 
354
366
  before do
355
- allow( subject ).to receive( :logger ).and_return( logger )
367
+ allow(subject).to receive(:logger).and_return(logger)
356
368
  end
357
369
 
358
370
  it 'returns an empty array if there are no applicable hosts' do
359
- hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'} ]
371
+ hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
360
372
 
361
- expect(subject.select_hosts( {'thing' => 'nope'}, hosts )).to be == []
373
+ expect(subject.select_hosts({ 'thing' => 'nope' }, hosts)).to be == []
362
374
  end
363
375
 
364
376
  it 'selects hosts that match a list of criteria' do
365
- hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'}, {'thing' => 'baz'} ]
377
+ hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
366
378
 
367
- expect(subject.select_hosts( {:thing => ['foo', 'baz']}, hosts )).to be == [ {'thing' => 'foo'}, {'thing' => 'baz'} ]
379
+ expect(subject.select_hosts({ :thing => %w[foo baz] }, hosts)).to be == [{ 'thing' => 'foo' }, { 'thing' => 'baz' }]
368
380
  end
369
381
 
370
382
  it 'selects hosts when a passed block returns true' do
371
- host1 = {'platform' => 'solaris1'}
372
- host2 = {'platform' => 'solaris2'}
373
- host3 = {'platform' => 'windows'}
383
+ host1 = { 'platform' => 'solaris1' }
384
+ host2 = { 'platform' => 'solaris2' }
385
+ host3 = { 'platform' => 'windows' }
374
386
  ret1 = double('result1')
375
- allow( ret1 ).to receive( :stdout ).and_return(':global')
387
+ allow(ret1).to receive(:stdout).and_return(':global')
376
388
  ret2 = double('result2')
377
- allow( ret2 ).to receive( :stdout ).and_return('a_zone')
378
- hosts = [ host1, host2, host3 ]
379
- expect( subject ).to receive( :hosts ).and_return( hosts )
389
+ allow(ret2).to receive(:stdout).and_return('a_zone')
390
+ hosts = [host1, host2, host3]
391
+ expect(subject).to receive(:hosts).and_return(hosts)
380
392
 
381
- expect( subject ).to receive( :on ).with( host1, '/sbin/zonename' ).once.and_return( ret1 )
382
- expect( subject ).to receive( :on ).with( host2, '/sbin/zonename' ).once.and_return( ret2 )
393
+ expect(subject).to receive(:on).with(host1, '/sbin/zonename').once.and_return(ret1)
394
+ expect(subject).to receive(:on).with(host2, '/sbin/zonename').once.and_return(ret2)
383
395
 
384
396
  selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host|
385
- subject.on(host, '/sbin/zonename').stdout.include?(':global')
397
+ subject.on(host, '/sbin/zonename').stdout.include?(':global')
386
398
  end
387
- expect( selected_hosts ).to be == [ host1 ]
399
+ expect(selected_hosts).to be == [host1]
388
400
  end
389
401
  end
390
-
391
402
  end