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
@@ -12,155 +12,154 @@ describe ClassMixedWithDSLStructure do
12
12
  let(:metadata) { @metadata ||= {} }
13
13
 
14
14
  before do
15
- allow( subject ).to receive(:metadata).and_return(metadata)
15
+ allow(subject).to receive(:metadata).and_return(metadata)
16
16
  end
17
17
 
18
18
  describe '#tag' do
19
- let( :test_tag_and ) { @test_tag_and || [] }
20
- let( :test_tag_or ) { @test_tag_or || [] }
21
- let( :test_tag_exclude ) { @test_tag_exclude || [] }
22
- let( :options ) {
19
+ let(:test_tag_and) { @test_tag_and || [] }
20
+ let(:test_tag_or) { @test_tag_or || [] }
21
+ let(:test_tag_exclude) { @test_tag_exclude || [] }
22
+ let(:options) do
23
23
  opts = Beaker::Options::OptionsHash.new
24
24
  opts[:test_tag_and] = test_tag_and
25
25
  opts[:test_tag_or] = test_tag_or
26
26
  opts[:test_tag_exclude] = test_tag_exclude
27
27
  opts
28
- }
28
+ end
29
29
 
30
30
  before do
31
- allow( subject ).to receive( :platform_specific_tag_confines )
31
+ allow(subject).to receive(:platform_specific_tag_confines)
32
32
  end
33
33
 
34
34
  it 'sets tags on the TestCase\'s metadata object' do
35
35
  subject.instance_variable_set(:@options, options)
36
- tags = ['pants', 'jayjay', 'moguely']
36
+ tags = %w[pants jayjay moguely]
37
37
  subject.tag(*tags)
38
- expect( metadata[:case][:tags] ).to be === tags
38
+ expect(metadata[:case][:tags]).to be === tags
39
39
  end
40
40
 
41
41
  it 'lowercases the tags' do
42
42
  subject.instance_variable_set(:@options, options)
43
- tags_upper = ['pANTs', 'jAYJAy', 'moGUYly']
43
+ tags_upper = %w[pANTs jAYJAy moGUYly]
44
44
  tags_lower = tags_upper.map(&:downcase)
45
45
  subject.tag(*tags_upper)
46
- expect( metadata[:case][:tags] ).to be === tags_lower
46
+ expect(metadata[:case][:tags]).to be === tags_lower
47
47
  end
48
48
 
49
49
  it 'skips the test if any of the requested tags isn\'t included in this test' do
50
- test_tags = ['pants', 'jayjay', 'moguely']
50
+ test_tags = %w[pants jayjay moguely]
51
51
  @test_tag_and = test_tags.compact.push('needed_tag_not_in_test')
52
52
  subject.instance_variable_set(:@options, options)
53
53
 
54
- allow( subject ).to receive( :path )
55
- expect( subject ).to receive( :skip_test )
54
+ allow(subject).to receive(:path)
55
+ expect(subject).to receive(:skip_test)
56
56
  subject.tag(*test_tags)
57
57
  end
58
58
 
59
59
  it 'runs the test if all requested tags are included in this test' do
60
- @test_tag_and = ['pants_on_head', 'jayjay_jayjay', 'mo']
60
+ @test_tag_and = %w[pants_on_head jayjay_jayjay mo]
61
61
  test_tags = @test_tag_and.compact.push('extra_asdf')
62
62
  subject.instance_variable_set(:@options, options)
63
63
 
64
- allow( subject ).to receive( :path )
65
- expect( subject ).not_to receive( :skip_test )
64
+ allow(subject).to receive(:path)
65
+ expect(subject).not_to receive(:skip_test)
66
66
  subject.tag(*test_tags)
67
67
  end
68
68
 
69
69
  it 'skips the test if any of the excluded tags are included in this test' do
70
- test_tags = ['ports', 'jay_john_mary', 'mog_the_dog']
70
+ test_tags = %w[ports jay_john_mary mog_the_dog]
71
71
  @test_tag_exclude = [test_tags[0]]
72
72
  subject.instance_variable_set(:@options, options)
73
73
 
74
- allow( subject ).to receive( :path )
75
- expect( subject ).to receive( :skip_test )
74
+ allow(subject).to receive(:path)
75
+ expect(subject).to receive(:skip_test)
76
76
  subject.tag(*test_tags)
77
77
  end
78
78
 
79
79
  it 'skips the test if an and-included & excluded tag are in this test' do
80
- test_tags = ['ports', 'jay_john_mary', 'mog_the_dog']
80
+ test_tags = %w[ports jay_john_mary mog_the_dog]
81
81
  @test_tag_and = [test_tags[1]]
82
82
  @test_tag_exclude = [test_tags[0]]
83
83
  subject.instance_variable_set(:@options, options)
84
84
 
85
- allow( subject ).to receive( :path )
86
- expect( subject ).to receive( :skip_test )
85
+ allow(subject).to receive(:path)
86
+ expect(subject).to receive(:skip_test)
87
87
  subject.tag(*test_tags)
88
88
  end
89
89
 
90
90
  it 'runs the test if none of the excluded tags are included in this test' do
91
- @test_tag_exclude = ['pants_on_head', 'jayjay_jayjay', 'mo']
92
- test_tags = ['pants_at_head', 'jayj00_jayjay', 'motly_crew']
91
+ @test_tag_exclude = %w[pants_on_head jayjay_jayjay mo]
92
+ test_tags = %w[pants_at_head jayj00_jayjay motly_crew]
93
93
  subject.instance_variable_set(:@options, options)
94
94
 
95
- allow( subject ).to receive( :path )
96
- expect( subject ).not_to receive( :skip_test )
95
+ allow(subject).to receive(:path)
96
+ expect(subject).not_to receive(:skip_test)
97
97
  subject.tag(*test_tags)
98
98
  end
99
99
 
100
100
  it 'skips the test if none of the OR tags are included in this test' do
101
- test_tags = ['portmanteau', 'foolios']
102
- @test_tag_or = ['fish', 'crayons', 'parkas']
101
+ test_tags = %w[portmanteau foolios]
102
+ @test_tag_or = %w[fish crayons parkas]
103
103
  subject.instance_variable_set(:@options, options)
104
104
 
105
- allow( subject ).to receive( :path )
106
- expect( subject ).to receive( :skip_test )
105
+ allow(subject).to receive(:path)
106
+ expect(subject).to receive(:skip_test)
107
107
  subject.tag(*test_tags)
108
108
  end
109
109
 
110
110
  it 'runs the test if only one of the OR tags are included in this test' do
111
- test_tags = ['portmanteau', 'foolios']
112
- @test_tag_or = ['foolios', 'crayons', 'parkas']
111
+ test_tags = %w[portmanteau foolios]
112
+ @test_tag_or = %w[foolios crayons parkas]
113
113
  subject.instance_variable_set(:@options, options)
114
114
 
115
- allow( subject ).to receive( :path )
116
- expect( subject ).not_to receive( :skip_test )
115
+ allow(subject).to receive(:path)
116
+ expect(subject).not_to receive(:skip_test)
117
117
  subject.tag(*test_tags)
118
118
  end
119
119
 
120
120
  it 'skips the test if an or-included & excluded tag are included in this test' do
121
- test_tags = ['ports', 'jay_john_mary', 'mog_the_dog']
121
+ test_tags = %w[ports jay_john_mary mog_the_dog]
122
122
  @test_tag_or = [test_tags[1]]
123
123
  @test_tag_exclude = [test_tags[0]]
124
124
  subject.instance_variable_set(:@options, options)
125
125
 
126
- allow( subject ).to receive( :path )
127
- expect( subject ).to receive( :skip_test )
126
+ allow(subject).to receive(:path)
127
+ expect(subject).to receive(:skip_test)
128
128
  subject.tag(*test_tags)
129
129
  end
130
130
  end
131
131
  end
132
132
 
133
133
  describe Beaker::DSL::TestTagging::PlatformTagConfiner do
134
- let( :confines_array ) { @confines_array || [] }
135
- let( :confiner ) {
136
- described_class.new( confines_array )
137
- }
134
+ let(:confines_array) { @confines_array || [] }
135
+ let(:confiner) do
136
+ described_class.new(confines_array)
137
+ end
138
138
 
139
139
  describe '#initialize' do
140
140
  it 'transforms one entry' do
141
141
  platform_regex = /^ubuntu$/
142
142
  tag_reason_hash = {
143
143
  'tag1' => 'reason1',
144
- 'tag2' => 'reason2'
144
+ 'tag2' => 'reason2',
145
145
  }
146
- @confines_array = [ {
147
- :platform => platform_regex,
148
- :tag_reason_hash => tag_reason_hash
149
- }
150
- ]
146
+ @confines_array = [{
147
+ :platform => platform_regex,
148
+ :tag_reason_hash => tag_reason_hash,
149
+ }]
151
150
 
152
- internal_hash = confiner.instance_variable_get( :@tag_confine_details_hash )
153
- expect( internal_hash.keys() ).to include( 'tag1' )
154
- expect( internal_hash.keys() ).to include( 'tag2' )
155
- expect( internal_hash.keys().length() ).to be === 2
151
+ internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
152
+ expect(internal_hash.keys).to include('tag1')
153
+ expect(internal_hash.keys).to include('tag2')
154
+ expect(internal_hash.keys.length).to be === 2
156
155
 
157
156
  tag_reason_hash.each do |tag, reason|
158
157
  tag_array = internal_hash[tag]
159
- expect( tag_array.length() ).to be === 1
158
+ expect(tag_array.length).to be === 1
160
159
  tag_hash = tag_array[0]
161
- expect( tag_hash[:platform_regex] ).to eql( platform_regex )
162
- expect( tag_hash[:log_message] ).to match( /#{reason}/ )
163
- expect( tag_hash[:type] ).to be === :except
160
+ expect(tag_hash[:platform_regex]).to eql(platform_regex)
161
+ expect(tag_hash[:log_message]).to match(/#{reason}/)
162
+ expect(tag_hash[:type]).to be === :except
164
163
  end
165
164
  end
166
165
 
@@ -170,25 +169,25 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
170
169
  :platform => /^el-/,
171
170
  :tag_reason_hash => {
172
171
  'tag1' => 'reason el 1',
173
- 'tag2' => 'reason2'
174
- }
172
+ 'tag2' => 'reason2',
173
+ },
175
174
  }, {
176
175
  :platform => /^cisco-/,
177
176
  :tag_reason_hash => {
178
177
  'tag1' => 'reason cisco 1',
179
- 'tag3' => 'reason3'
180
- }
181
- }
178
+ 'tag3' => 'reason3',
179
+ },
180
+ },
182
181
  ]
183
182
 
184
- internal_hash = confiner.instance_variable_get( :@tag_confine_details_hash )
185
- expect( internal_hash.keys() ).to include( 'tag1' )
186
- expect( internal_hash.keys() ).to include( 'tag2' )
187
- expect( internal_hash.keys() ).to include( 'tag3' )
188
- expect( internal_hash.keys().length() ).to be === 3
183
+ internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
184
+ expect(internal_hash.keys).to include('tag1')
185
+ expect(internal_hash.keys).to include('tag2')
186
+ expect(internal_hash.keys).to include('tag3')
187
+ expect(internal_hash.keys.length).to be === 3
189
188
 
190
189
  shared_tag_array = internal_hash['tag1']
191
- expect( shared_tag_array.length() ).to be === 2
190
+ expect(shared_tag_array.length).to be === 2
192
191
 
193
192
  platform_el_found = false
194
193
  platform_cisco_found = false
@@ -205,40 +204,40 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
205
204
  else
206
205
  log_msg = "unexpected log message for confine_details: "
207
206
  log_msg << confine_details[:log_message]
208
- fail( log_msg )
207
+ fail(log_msg)
209
208
  end
210
209
 
211
- expect( confine_details[:platform_regex] ).to eql( platform_to_match )
212
- expect( confine_details[:log_message] ).to match( reason_to_match )
210
+ expect(confine_details[:platform_regex]).to eql(platform_to_match)
211
+ expect(confine_details[:log_message]).to match(reason_to_match)
213
212
  end
214
- expect( platform_el_found ).to be === true
215
- expect( platform_cisco_found ).to be === true
213
+ expect(platform_el_found).to be === true
214
+ expect(platform_cisco_found).to be === true
216
215
  end
217
216
  end
218
217
 
219
218
  describe '#confine_details' do
220
219
  it 'returns an empty array if no tags match' do
221
- fake_confine_details_hash = { 'tag1' => [ {:type => 1}, {:type => 2} ]}
220
+ fake_confine_details_hash = { 'tag1' => [{ :type => 1 }, { :type => 2 }] }
222
221
  confiner.instance_variable_set(
223
222
  :@tag_confine_details_hash, fake_confine_details_hash
224
223
  )
225
- expect( confiner.confine_details( [ 'tag2', 'tag3' ] ) ).to be === []
224
+ expect(confiner.confine_details(%w[tag2 tag3])).to be === []
226
225
  end
227
226
 
228
227
  context 'descriminates on tag name' do
229
228
  fake_confine_details_hash = {
230
- 'tag0' => [ 10, 20, 30, 40 ],
231
- 'tag1' => [ 41, 51, 61, 71 ],
232
- 'tag2' => [ 22, 32, 42, 52 ],
233
- 'tag3' => [ 63, 73, 83, 93 ],
234
- 'tag4' => [ 34, 44, 54, 64 ],
229
+ 'tag0' => [10, 20, 30, 40],
230
+ 'tag1' => [41, 51, 61, 71],
231
+ 'tag2' => [22, 32, 42, 52],
232
+ 'tag3' => [63, 73, 83, 93],
233
+ 'tag4' => [34, 44, 54, 64],
235
234
  }
236
235
 
237
236
  key_combos_to_test = fake_confine_details_hash.keys.map { |key| [key] }
238
- key_combos_to_test << [ 'tag0', 'tag2' ]
239
- key_combos_to_test << [ 'tag1', 'tag4' ]
240
- key_combos_to_test << [ 'tag2', 'tag3', 'tag4' ]
241
- key_combos_to_test << fake_confine_details_hash.keys()
237
+ key_combos_to_test << %w[tag0 tag2]
238
+ key_combos_to_test << %w[tag1 tag4]
239
+ key_combos_to_test << %w[tag2 tag3 tag4]
240
+ key_combos_to_test << fake_confine_details_hash.keys
242
241
 
243
242
  before do
244
243
  confiner.instance_variable_set(
@@ -252,23 +251,23 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
252
251
  key_combo_to_have.each do |key_to_have|
253
252
  haves += fake_confine_details_hash[key_to_have]
254
253
  end
255
- keys_not_to_have = fake_confine_details_hash.keys.reject { |key_trial|
256
- key_combo_to_have.include?( key_trial )
257
- }
254
+ keys_not_to_have = fake_confine_details_hash.keys.reject do |key_trial|
255
+ key_combo_to_have.include?(key_trial)
256
+ end
258
257
  have_nots = []
259
258
  keys_not_to_have.each do |key_not_to_have|
260
259
  have_nots += fake_confine_details_hash[key_not_to_have]
261
260
  end
262
261
 
263
- details = confiner.confine_details( key_combo_to_have )
262
+ details = confiner.confine_details(key_combo_to_have)
264
263
  have_nots.each do |confine_details|
265
- expect( details ).not_to include( confine_details )
264
+ expect(details).not_to include(confine_details)
266
265
  end
267
266
  haves.each do |confine_details|
268
- expect( details ).to include( confine_details )
267
+ expect(details).to include(confine_details)
269
268
  end
270
269
  end
271
270
  end
272
271
  end
273
272
  end
274
- end
273
+ end
@@ -7,73 +7,72 @@ end
7
7
  describe ClassMixedWithDSLWrappers do
8
8
  describe '#host_command' do
9
9
  it 'delegates to HostCommand.new' do
10
- expect( Beaker::HostCommand ).to receive( :new ).with( 'blah' )
11
- subject.host_command( 'blah' )
10
+ expect(Beaker::HostCommand).to receive(:new).with('blah')
11
+ subject.host_command('blah')
12
12
  end
13
13
  end
14
14
 
15
15
  describe '#powershell' do
16
16
  it 'passes "powershell.exe <args> -Command <command>" to Command' do
17
17
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'")
18
- expect(command.command ).to be === 'powershell.exe'
19
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
20
- expect( command.options ).to be === {}
18
+ expect(command.command).to be === 'powershell.exe'
19
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
20
+ expect(command.options).to be === {}
21
21
  end
22
22
 
23
23
  it 'merges the arguments provided with the defaults' do
24
- command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'ExecutionPolicy' => 'Unrestricted'})
25
- expect( command.command).to be === 'powershell.exe'
26
- expect( command.args ).to be === ["-ExecutionPolicy Unrestricted", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
27
- expect( command.options ).to be === {}
24
+ command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'ExecutionPolicy' => 'Unrestricted' })
25
+ expect(command.command).to be === 'powershell.exe'
26
+ expect(command.args).to be === ["-ExecutionPolicy Unrestricted", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
27
+ expect(command.options).to be === {}
28
28
  end
29
29
 
30
30
  it 'uses EncodedCommand when EncodedCommand => true' do
31
31
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
32
32
  cmd = subject.encode_command(cmd)
33
- command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => true})
34
- expect(command.command ).to be === 'powershell.exe'
35
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
36
- expect( command.options ).to be === {}
33
+ command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => true })
34
+ expect(command.command).to be === 'powershell.exe'
35
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
36
+ expect(command.options).to be === {}
37
37
  end
38
38
 
39
39
  it 'uses EncodedCommand when EncodedCommand => ""' do
40
40
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
41
41
  cmd = subject.encode_command(cmd)
42
- command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => ""})
43
- expect(command.command ).to be === 'powershell.exe'
44
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
45
- expect( command.options ).to be === {}
42
+ command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => "" })
43
+ expect(command.command).to be === 'powershell.exe'
44
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
45
+ expect(command.options).to be === {}
46
46
  end
47
47
 
48
48
  it 'uses EncodedCommand when EncodedCommand => nil' do
49
49
  cmd = "Set-Content -path 'fu.txt' -value 'fu'"
50
50
  cmd = subject.encode_command(cmd)
51
- command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => nil})
52
- expect(command.command ).to be === 'powershell.exe'
53
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
54
- expect( command.options ).to be === {}
51
+ command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => nil })
52
+ expect(command.command).to be === 'powershell.exe'
53
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
54
+ expect(command.options).to be === {}
55
55
  end
56
56
 
57
57
  it 'does not use EncodedCommand when EncodedCommand => false' do
58
- command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => false})
59
- expect(command.command ).to be === 'powershell.exe'
60
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
61
- expect( command.options ).to be === {}
58
+ command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => false })
59
+ expect(command.command).to be === 'powershell.exe'
60
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
61
+ expect(command.options).to be === {}
62
62
  end
63
63
 
64
64
  it 'does not use EncodedCommand when EncodedCommand not present' do
65
65
  command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {})
66
- expect(command.command ).to be === 'powershell.exe'
67
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
68
- expect( command.options ).to be === {}
66
+ expect(command.command).to be === 'powershell.exe'
67
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
68
+ expect(command.options).to be === {}
69
69
  end
70
70
 
71
71
  it 'has no -Command/-EncodedCommand when command is empty' do
72
- command = subject.powershell("", {"File" => 'myfile.ps1'})
73
- expect(command.command ).to be === 'powershell.exe'
74
- expect( command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-File myfile.ps1"]
75
- expect( command.options ).to be === {}
76
-
72
+ command = subject.powershell("", { "File" => 'myfile.ps1' })
73
+ expect(command.command).to be === 'powershell.exe'
74
+ expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-File myfile.ps1"]
75
+ expect(command.options).to be === {}
77
76
  end
78
77
  end
79
78
  end
@@ -3,49 +3,49 @@ require 'spec_helper'
3
3
  module Aix
4
4
  describe Host do
5
5
  let(:options) { @options ? @options : {} }
6
- let(:platform) {
6
+ let(:platform) do
7
7
  if @platform
8
- { :platform => Beaker::Platform.new( @platform) }
8
+ { :platform => Beaker::Platform.new(@platform) }
9
9
  else
10
- { :platform => Beaker::Platform.new( 'aix-vers-arch-extra' ) }
10
+ { :platform => Beaker::Platform.new('aix-vers-arch-extra') }
11
11
  end
12
- }
13
- let(:host) { make_host( 'name', options.merge(platform) ) }
12
+ end
13
+ let(:host) { make_host('name', options.merge(platform)) }
14
14
 
15
15
  describe '#ssh_service_restart' do
16
16
  it 'invokes the correct commands on the host' do
17
- expect( Beaker::Command ).to receive( :new ).with( 'stopsrc -g ssh' ).once.ordered
18
- expect( Beaker::Command ).to receive( :new ).with( 'startsrc -g ssh' ).once.ordered
17
+ expect(Beaker::Command).to receive(:new).with('stopsrc -g ssh').once.ordered
18
+ expect(Beaker::Command).to receive(:new).with('startsrc -g ssh').once.ordered
19
19
  host.ssh_service_restart
20
20
  end
21
21
  end
22
22
 
23
23
  describe '#ssh_permit_user_environment' do
24
24
  it 'calls echo to set PermitUserEnvironment' do
25
- expect( Beaker::Command ).to receive( :new ).with( /^echo\ / ).once.ordered
26
- allow( host ).to receive( :ssh_service_restart )
25
+ expect(Beaker::Command).to receive(:new).with(/^echo\ /).once.ordered
26
+ allow(host).to receive(:ssh_service_restart)
27
27
  host.ssh_permit_user_environment
28
28
  end
29
29
 
30
30
  it 'uses the correct ssh config file' do
31
- expect( Beaker::Command ).to receive( :new ).with( /#{Regexp.escape(' >> /etc/ssh/sshd_config')}$/ ).once
32
- allow( host ).to receive( :ssh_service_restart )
31
+ expect(Beaker::Command).to receive(:new).with(/#{Regexp.escape(' >> /etc/ssh/sshd_config')}$/).once
32
+ allow(host).to receive(:ssh_service_restart)
33
33
  host.ssh_permit_user_environment
34
34
  end
35
35
  end
36
36
 
37
37
  describe '#reboot' do
38
38
  it 'invokes the correct command on the host' do
39
- expect( Beaker::Command ).to receive( :new ).with( 'shutdown -Fr' ).once
39
+ expect(Beaker::Command).to receive(:new).with('shutdown -Fr').once
40
40
  host.reboot
41
41
  end
42
42
  end
43
43
 
44
44
  describe '#get_ip' do
45
45
  it 'invokes the correct command on the host' do
46
- expect( host ).to receive( :execute ).with( /^ifconfig\ \-a\ inet\|\ / ).once.and_return( '' )
46
+ expect(host).to receive(:execute).with(/^ifconfig\ \-a\ inet\|\ /).once.and_return('')
47
47
  host.get_ip
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end