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
@@ -1,134 +1,132 @@
1
1
  require 'spec_helper'
2
2
 
3
-
4
3
  class ClassMixedWithDSLRoles
5
4
  include Beaker::DSL::Roles
6
5
  include Beaker::DSL::Outcomes
7
6
  end
8
7
 
9
8
  describe ClassMixedWithDSLRoles do
10
-
11
- let( :hosts ) { @hosts || Hash.new }
12
- let( :options ) { @options || Hash.new }
13
- let( :agent1 ) { make_host( 'agent1', { :roles => [ 'agent' ] } ) }
14
- let( :agent2 ) { make_host( 'agent2', { :roles => [ 'agent' ] } ) }
15
- let( :a_and_dash ) { make_host( 'a_and_dash', { :roles => [ 'agent', 'dashboard' ] } ) }
16
- let( :custom ) { make_host( 'custom', { :roles => [ 'custom_role' ] } ) }
17
- let( :db ) { make_host( 'db', { :roles => [ 'database' ] } ) }
18
- let( :master ) { make_host( 'master', { :roles => [ 'master', 'agent' ] } ) }
19
- let( :default ) { make_host( 'default', { :roles => [ 'default'] } ) }
20
- let( :monolith ) { make_host( 'monolith', { :roles => [ 'agent', 'dashboard', 'database', 'master', 'custom_role'] } ) }
9
+ let(:hosts) { @hosts || {} }
10
+ let(:options) { @options || {} }
11
+ let(:agent1) { make_host('agent1', { :roles => ['agent'] }) }
12
+ let(:agent2) { make_host('agent2', { :roles => ['agent'] }) }
13
+ let(:a_and_dash) { make_host('a_and_dash', { :roles => %w[agent dashboard] }) }
14
+ let(:custom) { make_host('custom', { :roles => ['custom_role'] }) }
15
+ let(:db) { make_host('db', { :roles => ['database'] }) }
16
+ let(:master) { make_host('master', { :roles => %w[master agent] }) }
17
+ let(:default) { make_host('default', { :roles => ['default'] }) }
18
+ let(:monolith) { make_host('monolith', { :roles => %w[agent dashboard database master custom_role] }) }
21
19
 
22
20
  describe '#agents' do
23
21
  it 'returns an array of hosts that are agents' do
24
- @hosts = [ agent1, agent2, master ]
25
- expect( subject ).to receive( :hosts ).and_return( hosts )
26
- expect( subject.agents ).to be == [ agent1, agent2, master ]
22
+ @hosts = [agent1, agent2, master]
23
+ expect(subject).to receive(:hosts).and_return(hosts)
24
+ expect(subject.agents).to be == [agent1, agent2, master]
27
25
  end
28
26
 
29
27
  it 'and an empty array when none match' do
30
- @hosts = [ db, custom ]
31
- expect( subject ).to receive( :hosts ).and_return( hosts )
32
- expect( subject.agents ).to be == []
28
+ @hosts = [db, custom]
29
+ expect(subject).to receive(:hosts).and_return(hosts)
30
+ expect(subject.agents).to be == []
33
31
  end
34
32
  end
35
33
 
36
34
  describe '#master' do
37
35
  it 'returns the master if there is one' do
38
- @hosts = [ master, agent1 ]
39
- expect( subject ).to receive( :hosts ).and_return( hosts )
40
- expect( subject.master ).to be == master
36
+ @hosts = [master, agent1]
37
+ expect(subject).to receive(:hosts).and_return(hosts)
38
+ expect(subject.master).to be == master
41
39
  end
42
40
 
43
41
  it 'raises an error if there is more than one master' do
44
- @hosts = [ master, monolith ]
45
- expect( subject ).to receive( :hosts ).once.and_return( hosts )
42
+ @hosts = [master, monolith]
43
+ expect(subject).to receive(:hosts).once.and_return(hosts)
46
44
  expect { subject.master }.to raise_error Beaker::DSL::FailTest
47
45
  end
48
46
 
49
47
  it 'returns nil if no master and masterless is set' do
50
48
  @options = { :masterless => true }
51
- expect( subject ).to receive( :hosts ).and_return( hosts )
52
- expect( subject ).to receive( :options ).and_return( options )
53
- expect( subject.master ).to be_nil
49
+ expect(subject).to receive(:hosts).and_return(hosts)
50
+ expect(subject).to receive(:options).and_return(options)
51
+ expect(subject.master).to be_nil
54
52
  end
55
53
  end
56
54
 
57
55
  describe '#dashboard' do
58
56
  it 'returns the dashboard if there is one' do
59
- @hosts = [ a_and_dash, agent1 ]
60
- expect( subject ).to receive( :hosts ).and_return( hosts )
61
- expect( subject.dashboard ).to be == a_and_dash
57
+ @hosts = [a_and_dash, agent1]
58
+ expect(subject).to receive(:hosts).and_return(hosts)
59
+ expect(subject.dashboard).to be == a_and_dash
62
60
  end
63
61
 
64
62
  it 'raises an error if there is more than one dashboard' do
65
- @hosts = [ a_and_dash, monolith ]
66
- expect( subject ).to receive( :hosts ).and_return( hosts )
63
+ @hosts = [a_and_dash, monolith]
64
+ expect(subject).to receive(:hosts).and_return(hosts)
67
65
  expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
68
66
  end
69
67
 
70
68
  it 'and raises an error if there is no dashboard' do
71
- @hosts = [ agent1, agent2, custom ]
72
- expect( subject ).to receive( :hosts ).and_return( hosts )
69
+ @hosts = [agent1, agent2, custom]
70
+ expect(subject).to receive(:hosts).and_return(hosts)
73
71
  expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
74
72
  end
75
73
 
76
74
  it 'returns nil if no dashboard and masterless is set' do
77
75
  @options = { :masterless => true }
78
- expect( subject ).to receive( :hosts ).and_return( hosts )
79
- expect( subject ).to receive( :options ).and_return( options )
80
- expect( subject.dashboard ).to be_nil
76
+ expect(subject).to receive(:hosts).and_return(hosts)
77
+ expect(subject).to receive(:options).and_return(options)
78
+ expect(subject.dashboard).to be_nil
81
79
  end
82
80
  end
83
81
 
84
82
  describe '#database' do
85
83
  it 'returns the database if there is one' do
86
- @hosts = [ db, agent1 ]
87
- expect( subject ).to receive( :hosts ).and_return( hosts )
88
- expect( subject.database ).to be == db
84
+ @hosts = [db, agent1]
85
+ expect(subject).to receive(:hosts).and_return(hosts)
86
+ expect(subject.database).to be == db
89
87
  end
90
88
 
91
89
  it 'raises an error if there is more than one database' do
92
- @hosts = [ db, monolith ]
93
- expect( subject ).to receive( :hosts ).and_return( hosts )
90
+ @hosts = [db, monolith]
91
+ expect(subject).to receive(:hosts).and_return(hosts)
94
92
  expect { subject.database }.to raise_error Beaker::DSL::FailTest
95
93
  end
96
94
 
97
95
  it 'and raises an error if there is no database' do
98
- @hosts = [ agent1, agent2, custom ]
99
- expect( subject ).to receive( :hosts ).and_return( hosts )
96
+ @hosts = [agent1, agent2, custom]
97
+ expect(subject).to receive(:hosts).and_return(hosts)
100
98
  expect { subject.database }.to raise_error Beaker::DSL::FailTest
101
99
  end
102
100
 
103
101
  it 'returns nil if no database and masterless is set' do
104
102
  @options = { :masterless => true }
105
- expect( subject ).to receive( :hosts ).and_return( hosts )
106
- expect( subject ).to receive( :options ).and_return( options )
107
- expect( subject.database ).to be_nil
103
+ expect(subject).to receive(:hosts).and_return(hosts)
104
+ expect(subject).to receive(:options).and_return(options)
105
+ expect(subject.database).to be_nil
108
106
  end
109
107
  end
110
108
 
111
109
  describe '#not_controller' do
112
110
  it 'returns true when a host does not have the roles master/database/dashboard' do
113
- expect( subject.not_controller(agent1) ).to be == true
111
+ expect(subject.not_controller(agent1)).to be == true
114
112
  end
115
113
 
116
114
  it 'returns false when a host has one of the roles master/database/dashboard' do
117
- expect( subject.not_controller(a_and_dash) ).to be == false
115
+ expect(subject.not_controller(a_and_dash)).to be == false
118
116
  end
119
117
  end
120
118
 
121
119
  describe '#agent_only' do
122
120
  it 'returns true when a host has the single role agent' do
123
- expect( subject.agent_only(agent1) ).to be == true
121
+ expect(subject.agent_only(agent1)).to be == true
124
122
  end
125
123
 
126
124
  it 'returns false when a host has more than a single role' do
127
- expect( subject.agent_only(a_and_dash) ).to be == false
125
+ expect(subject.agent_only(a_and_dash)).to be == false
128
126
  end
129
127
 
130
128
  it 'returns false when a host has the role master' do
131
- expect( subject.agent_only(master) ).to be == false
129
+ expect(subject.agent_only(master)).to be == false
132
130
  end
133
131
  end
134
132
 
@@ -136,73 +134,72 @@ describe ClassMixedWithDSLRoles do
136
134
  it 'returns false if the host doesn\'t have a :pe_ver or :version' do
137
135
  agent1[:pe_ver] = nil
138
136
  agent1[:version] = nil
139
- expect( subject.aio_version?(agent1) ).to be === false
137
+ expect(subject.aio_version?(agent1)).to be === false
140
138
  end
141
139
 
142
140
  it 'returns false if :version < 4.0 and pe_ver is nil, type foss' do
143
141
  agent1[:pe_ver] = nil
144
142
  agent1[:version] = '3.8'
145
143
  agent1[:type] = 'foss'
146
- expect( subject.aio_version?(agent1) ).to be === false
144
+ expect(subject.aio_version?(agent1)).to be === false
147
145
  end
148
146
 
149
147
  it 'returns false if the host :pe_ver is set < 4.0' do
150
148
  agent1[:pe_ver] = '3.8'
151
- expect( subject.aio_version?(agent1) ).to be === false
149
+ expect(subject.aio_version?(agent1)).to be === false
152
150
  end
153
151
 
154
152
  it 'returns false if the host :version is set < 4.0' do
155
153
  agent1[:version] = '3.8'
156
- expect( subject.aio_version?(agent1) ).to be === false
154
+ expect(subject.aio_version?(agent1)).to be === false
157
155
  end
158
156
 
159
157
  it 'returns true if the host :pe_ver is 4.0' do
160
158
  agent1[:pe_ver] = '4.0'
161
- expect( subject.aio_version?(agent1) ).to be === true
159
+ expect(subject.aio_version?(agent1)).to be === true
162
160
  end
163
161
 
164
162
  it 'returns true if the host :version is 4.0' do
165
163
  agent1[:version] = '4.0'
166
- expect( subject.aio_version?(agent1) ).to be === true
164
+ expect(subject.aio_version?(agent1)).to be === true
167
165
  end
168
166
 
169
167
  it 'returns true if the host :pe_ver is 2015.5' do
170
168
  agent1[:pe_ver] = '2015.5'
171
- expect( subject.aio_version?(agent1) ).to be === true
169
+ expect(subject.aio_version?(agent1)).to be === true
172
170
  end
173
171
 
174
172
  it 'returns true if the host has role aio' do
175
173
  agent1[:roles] = agent1[:roles] | ['aio']
176
- expect( subject.aio_version?(agent1) ).to be === true
174
+ expect(subject.aio_version?(agent1)).to be === true
177
175
  end
178
176
 
179
177
  it 'returns true if the host is type aio' do
180
178
  agent1[:type] = 'aio'
181
- expect( subject.aio_version?(agent1) ).to be === true
179
+ expect(subject.aio_version?(agent1)).to be === true
182
180
  end
183
181
 
184
182
  it 'returns true if the host is type aio-foss' do
185
183
  agent1[:type] = 'aio-foss'
186
- expect( subject.aio_version?(agent1) ).to be === true
184
+ expect(subject.aio_version?(agent1)).to be === true
187
185
  end
188
186
 
189
187
  it 'returns true if the host is type foss-aio' do
190
188
  agent1[:type] = 'aio-foss'
191
- expect( subject.aio_version?(agent1) ).to be === true
189
+ expect(subject.aio_version?(agent1)).to be === true
192
190
  end
193
191
 
194
192
  it 'can take an empty string for pe_ver' do
195
193
  agent1[:pe_ver] = ''
196
- expect{ subject.aio_version?(agent1) }.not_to raise_error
194
+ expect { subject.aio_version?(agent1) }.not_to raise_error
197
195
  end
198
196
 
199
197
  it 'can take an empty string for FOSS version' do
200
198
  agent1[:version] = ''
201
- expect{ subject.aio_version?(agent1) }.not_to raise_error
199
+ expect { subject.aio_version?(agent1) }.not_to raise_error
202
200
  end
203
201
 
204
202
  context 'truth table-type testing' do
205
-
206
203
  before do
207
204
  @old_pe_ver = agent1[:pe_ver]
208
205
  @old_version = agent1[:version]
@@ -220,32 +217,32 @@ describe ClassMixedWithDSLRoles do
220
217
  context 'version values table' do
221
218
  # pe_ver, version, answer
222
219
  versions_table = [
223
- [nil, nil, false],
224
- [nil, '', false],
220
+ [nil, nil, false],
221
+ [nil, '', false],
225
222
  [nil, '3.9', false],
226
- [nil, '4.0', true ],
227
- [nil, '2015.1', true ],
228
- \
229
- ['', nil, false],
230
- ['', '', false],
223
+ [nil, '4.0', true],
224
+ [nil, '2015.1', true],
225
+ \
226
+ ['', nil, false],
227
+ ['', '', false],
231
228
  ['', '3.9', false],
232
- ['', '4.0', true ],
233
- ['', '2015.1', true ],
234
- \
235
- ['3.9', nil, false],
236
- ['3.9', '', false],
229
+ ['', '4.0', true],
230
+ ['', '2015.1', true],
231
+ \
232
+ ['3.9', nil, false],
233
+ ['3.9', '', false],
237
234
  ['3.9', '3.9', false],
238
235
  ['3.9', '4.0', false],
239
236
  ['3.9', '2015.1', false],
240
- \
241
- ['4.0', nil, true],
242
- ['4.0', '', true],
237
+ \
238
+ ['4.0', nil, true],
239
+ ['4.0', '', true],
243
240
  ['4.0', '3.9', true],
244
241
  ['4.0', '4.0', true],
245
242
  ['4.0', '2015.1', true],
246
- \
247
- ['2015.1', nil, true],
248
- ['2015.1', '', true],
243
+ \
244
+ ['2015.1', nil, true],
245
+ ['2015.1', '', true],
249
246
  ['2015.1', '3.9', true],
250
247
  ['2015.1', '4.0', true],
251
248
  ['2015.1', '2015.1', true],
@@ -257,7 +254,7 @@ describe ClassMixedWithDSLRoles do
257
254
  agent1[:version] = answers_row[1]
258
255
  agent1[:roles] = nil
259
256
  agent1[:type] = nil
260
- expect( subject.aio_version?(agent1) ).to be === answers_row[2]
257
+ expect(subject.aio_version?(agent1)).to be === answers_row[2]
261
258
  end
262
259
  end
263
260
  end
@@ -266,10 +263,10 @@ describe ClassMixedWithDSLRoles do
266
263
  roles_table = [
267
264
  [nil, false],
268
265
  [[], false],
269
- [['aio'], true ],
266
+ [['aio'], true],
270
267
  [['gun'], false],
271
- [['a', 'b'], false],
272
- [['c', 'aio'], true ],
268
+ [%w[a b], false],
269
+ [%w[c aio], true],
273
270
  ]
274
271
 
275
272
  roles_table.each do |answers_row|
@@ -278,7 +275,7 @@ describe ClassMixedWithDSLRoles do
278
275
  agent1[:version] = nil
279
276
  agent1[:roles] = answers_row[0]
280
277
  agent1[:type] = nil
281
- expect( subject.aio_version?(agent1) ).to be === answers_row[1]
278
+ expect(subject.aio_version?(agent1)).to be === answers_row[1]
282
279
  end
283
280
  end
284
281
  end
@@ -291,9 +288,9 @@ describe ClassMixedWithDSLRoles do
291
288
  ['paionts', false],
292
289
  ['aioch', false],
293
290
  ['chaio', false],
294
- ['aio', true ],
295
- ['aio-', true ],
296
- ['ew-aio-ji', true ],
291
+ ['aio', true],
292
+ ['aio-', true],
293
+ ['ew-aio-ji', true],
297
294
  ['id-aiot', false],
298
295
  ]
299
296
 
@@ -303,107 +300,105 @@ describe ClassMixedWithDSLRoles do
303
300
  agent1[:version] = nil
304
301
  agent1[:roles] = nil
305
302
  agent1[:type] = answers_row[0]
306
- expect( subject.aio_version?(agent1) ).to be === answers_row[1]
303
+ expect(subject.aio_version?(agent1)).to be === answers_row[1]
307
304
  end
308
305
  end
309
306
  end
310
-
311
307
  end
312
-
313
308
  end
314
309
 
315
310
  describe '#aio_agent?' do
316
311
  it 'returns false if agent_only check doesn\'t pass' do
317
- agent1[:roles] = ['agent', 'headless']
318
- expect( subject.aio_agent?(agent1) ).to be === false
312
+ agent1[:roles] = %w[agent headless]
313
+ expect(subject.aio_agent?(agent1)).to be === false
319
314
  end
320
315
 
321
316
  it 'returns false if aio_capable? check doesn\'t pass' do
322
317
  agent1[:pe_ver] = '3.8'
323
- expect( subject.aio_agent?(agent1) ).to be === false
318
+ expect(subject.aio_agent?(agent1)).to be === false
324
319
  end
325
320
 
326
321
  it 'returns true if both checks pass' do
327
322
  agent1[:pe_ver] = '4.0'
328
- expect( subject.aio_agent?(agent1) ).to be === true
323
+ expect(subject.aio_agent?(agent1)).to be === true
329
324
  end
330
325
  end
331
326
 
332
327
  describe '#default' do
333
328
  it 'returns the default host when one is specified' do
334
- @hosts = [ db, agent1, agent2, default, master]
335
- expect( subject ).to receive( :hosts ).once.and_return( hosts )
336
- expect( subject.default ).to be == default
329
+ @hosts = [db, agent1, agent2, default, master]
330
+ expect(subject).to receive(:hosts).once.and_return(hosts)
331
+ expect(subject.default).to be == default
337
332
  end
338
333
 
339
334
  it 'raises an error if there is more than one default' do
340
- @hosts = [ db, monolith, default, default ]
341
- expect( subject ).to receive( :hosts ).and_return( hosts )
335
+ @hosts = [db, monolith, default, default]
336
+ expect(subject).to receive(:hosts).and_return(hosts)
342
337
  expect { subject.default }.to raise_error Beaker::DSL::FailTest
343
338
  end
344
339
 
345
340
  it 'and raises an error if there is no default' do
346
- @hosts = [ agent1, agent2, custom ]
347
- expect( subject ).to receive( :hosts ).and_return( hosts )
341
+ @hosts = [agent1, agent2, custom]
342
+ expect(subject).to receive(:hosts).and_return(hosts)
348
343
  expect { subject.default }.to raise_error Beaker::DSL::FailTest
349
344
  end
350
345
 
351
346
  it 'returns nil if no default and masterless is set' do
352
347
  @options = { :masterless => true }
353
- expect( subject ).to receive( :hosts ).and_return( hosts )
354
- expect( subject ).to receive( :options ).and_return( options )
355
- expect( subject.default ).to be_nil
348
+ expect(subject).to receive(:hosts).and_return(hosts)
349
+ expect(subject).to receive(:options).and_return(options)
350
+ expect(subject.default).to be_nil
356
351
  end
357
352
  end
358
353
 
359
354
  describe '#add_role_def' do
360
355
  it 'raises an error on unsupported role format "1role"' do
361
- expect { subject.add_role_def( "1role" ) }.to raise_error ArgumentError
356
+ expect { subject.add_role_def("1role") }.to raise_error ArgumentError
362
357
  end
363
358
 
364
359
  it 'raises an error on unsupported role format "role_!a"' do
365
- expect { subject.add_role_def( "role_!a" ) }.to raise_error ArgumentError
360
+ expect { subject.add_role_def("role_!a") }.to raise_error ArgumentError
366
361
  end
367
362
 
368
363
  it 'raises an error on unsupported role format "role=="' do
369
- expect { subject.add_role_def( "role==" ) }.to raise_error ArgumentError
364
+ expect { subject.add_role_def("role==") }.to raise_error ArgumentError
370
365
  end
371
366
 
372
367
  it 'creates new method for role "role_correct!"' do
373
368
  test_role = "role_correct!"
374
- subject.add_role_def( test_role )
375
- expect( subject ).to respond_to test_role
376
- subject.class.send( :undef_method, test_role )
369
+ subject.add_role_def(test_role)
370
+ expect(subject).to respond_to test_role
371
+ subject.class.send(:undef_method, test_role)
377
372
  end
378
373
 
379
374
  it 'returns a single node for a new method for a role defined in a single node' do
380
- @hosts = [ agent1, agent2, monolith ]
381
- expect( subject ).to receive( :hosts ).and_return( hosts )
375
+ @hosts = [agent1, agent2, monolith]
376
+ expect(subject).to receive(:hosts).and_return(hosts)
382
377
  test_role = "custom_role"
383
- subject.add_role_def( test_role )
384
- expect( subject ).to respond_to test_role
385
- expect( subject.send( test_role )).to be == @hosts[2]
386
- subject.class.send( :undef_method, test_role )
378
+ subject.add_role_def(test_role)
379
+ expect(subject).to respond_to test_role
380
+ expect(subject.send(test_role)).to be == @hosts[2]
381
+ subject.class.send(:undef_method, test_role)
387
382
  end
388
383
 
389
384
  it 'returns an array of nodes for a new method for a role defined in multiple nodes' do
390
- @hosts = [ agent1, agent2, monolith, custom ]
391
- expect( subject ).to receive( :hosts ).and_return( hosts )
385
+ @hosts = [agent1, agent2, monolith, custom]
386
+ expect(subject).to receive(:hosts).and_return(hosts)
392
387
  test_role = "custom_role"
393
- subject.add_role_def( test_role )
394
- expect( subject ).to respond_to test_role
395
- expect( subject.send( test_role )).to be == [@hosts[2], @hosts[3]]
396
- subject.class.send( :undef_method, test_role )
388
+ subject.add_role_def(test_role)
389
+ expect(subject).to respond_to test_role
390
+ expect(subject.send(test_role)).to be == [@hosts[2], @hosts[3]]
391
+ subject.class.send(:undef_method, test_role)
397
392
  end
398
393
  end
399
394
 
400
395
  describe '#any_hosts_as?' do
401
396
  it 'returns true if a host exists, false otherwise' do
402
- @hosts = [ agent1, agent2 ]
397
+ @hosts = [agent1, agent2]
403
398
  # expect( subject ).to receive( :hosts ).and_return( hosts )
404
- expect( subject ).to receive( :hosts ).twice.and_return( hosts )
405
- expect( subject.any_hosts_as?( "agent" )).to be == true
406
- expect( subject.any_hosts_as?( "custom_role" )).to be == false
399
+ expect(subject).to receive(:hosts).twice.and_return(hosts)
400
+ expect(subject.any_hosts_as?("agent")).to be == true
401
+ expect(subject.any_hosts_as?("custom_role")).to be == false
407
402
  end
408
403
  end
409
404
  end