beaker 4.41.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -3,25 +3,23 @@ require "spec_helper"
3
3
  module Beaker
4
4
  module Options
5
5
  describe CommandLineParser do
6
-
7
- let(:parser) {described_class.new}
8
- let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
9
- let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--pre-cleanup", "pre_cleanup.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--no-color-host-output", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--test-tag-and", "1,2,3", "--test-tag-or", "4,5,6", "--test-tag-exclude", "7,8,9", "--xml-time-order"]}
10
- let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :pre_cleanup => "pre_cleanup.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :color_host_output=>false, :beaker_version_print=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>"normal", :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :test_tag_and => "1,2,3", :test_tag_or => "4,5,6", :test_tag_exclude => "7,8,9", :xml_time_enabled => true}}
11
- let(:validate_true) {["--validate"]}
12
- let(:validate_false) {["--no-validate"]}
13
- let(:configure_true) {['--configure']}
14
- let(:configure_false) {['--no-configure']}
15
- let(:provision_false) {['--no-provision']}
16
- let(:provision_other) {{:provision => false, :configure => false, :validate => false}}
17
- let(:provision_both_in) {['--no-provision', '--configure', '--validate']}
18
- let(:provision_both_out) {{:provision => false, :configure => true, :validate => true}}
19
- let(:provision_half_in) {['--no-provision', '--configure']}
20
- let(:provision_half_out) {{:provision => false, :configure => true, :validate => false}}
21
-
6
+ let(:parser) { described_class.new }
7
+ let(:test_opts) { ["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"] }
8
+ let(:full_opts_in) { ["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--pre-cleanup", "pre_cleanup.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--no-color-host-output", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--test-tag-and", "1,2,3", "--test-tag-or", "4,5,6", "--test-tag-exclude", "7,8,9", "--xml-time-order"] }
9
+ let(:full_opts_out) { { :hosts_file => "anotherfile.cfg", :options_file => "opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :pre_cleanup => "pre_cleanup.rb", :provision => false, :preserve_hosts => "always", :root_keys => true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules => "module", :quiet => true, :dry_run => true, :timesync => false, :repo_proxy => true, :fail_mode => "fast", :color => false, :color_host_output => false, :beaker_version_print => true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data => "normal", :parse_only => true, :validate => true, :timeout => "40", :log_prefix => "pants", :configure => true, :test_tag_and => "1,2,3", :test_tag_or => "4,5,6", :test_tag_exclude => "7,8,9", :xml_time_enabled => true } }
10
+ let(:validate_true) { ["--validate"] }
11
+ let(:validate_false) { ["--no-validate"] }
12
+ let(:configure_true) { ['--configure'] }
13
+ let(:configure_false) { ['--no-configure'] }
14
+ let(:provision_false) { ['--no-provision'] }
15
+ let(:provision_other) { { :provision => false, :configure => false, :validate => false } }
16
+ let(:provision_both_in) { ['--no-provision', '--configure', '--validate'] }
17
+ let(:provision_both_out) { { :provision => false, :configure => true, :validate => true } }
18
+ let(:provision_half_in) { ['--no-provision', '--configure'] }
19
+ let(:provision_half_out) { { :provision => false, :configure => true, :validate => false } }
22
20
 
23
21
  it "can correctly read command line input" do
24
- expect(parser.parse(test_opts)).to be === {:hosts_file=>"vcloud.cfg", :log_level=>"debug", :tests=>"test.rb", :help=>true}
22
+ expect(parser.parse(test_opts)).to be === { :hosts_file => "vcloud.cfg", :log_level => "debug", :tests => "test.rb", :help => true }
25
23
  end
26
24
 
27
25
  it "supports all our command line options" do
@@ -29,17 +27,17 @@ module Beaker
29
27
  end
30
28
 
31
29
  it "supports both validate options" do
32
- expect(parser.parse(validate_true)).to be === {:validate=>true}
33
- expect(parser.parse(validate_false)).to be === {:validate=>false}
30
+ expect(parser.parse(validate_true)).to be === { :validate => true }
31
+ expect(parser.parse(validate_false)).to be === { :validate => false }
34
32
  end
35
33
 
36
34
  it 'supports both configure options' do
37
- expect(parser.parse(configure_true)).to be === {:configure=>true}
38
- expect(parser.parse(configure_false)).to be === {:configure=>false}
35
+ expect(parser.parse(configure_true)).to be === { :configure => true }
36
+ expect(parser.parse(configure_false)).to be === { :configure => false }
39
37
  end
40
38
 
41
39
  it "can produce a usage description" do
42
- expect{parser.usage}.not_to raise_error
40
+ expect { parser.usage }.not_to raise_error
43
41
  end
44
42
 
45
43
  context '--no-provision flag effects other options' do
@@ -55,7 +53,6 @@ module Beaker
55
53
  expect(parser.parse(provision_half_in)).to be === provision_half_out
56
54
  end
57
55
  end
58
-
59
56
  end
60
57
  end
61
58
  end
@@ -3,16 +3,15 @@ require "spec_helper"
3
3
  module Beaker
4
4
  module Options
5
5
  describe HostsFileParser do
6
-
7
- let(:parser) {described_class}
8
- let(:filepath) {File.join(File.expand_path(File.dirname(__FILE__)), "data", "hosts.cfg")}
9
- let(:filepath_yaml) {File.join(File.expand_path(File.dirname(__FILE__)), "data", "hosts_preserved.yml")}
6
+ let(:parser) { described_class }
7
+ let(:filepath) { File.join(__dir__, "data", "hosts.cfg") }
8
+ let(:filepath_yaml) { File.join(__dir__, "data", "hosts_preserved.yml") }
10
9
 
11
10
  describe '#parse_hosts_file' do
12
11
  it "can correctly read a host file" do
13
12
  FakeFS.deactivate!
14
13
  config = parser.parse_hosts_file(filepath)
15
- expect(config).to be === {:HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :consoleport=>443}
14
+ expect(config).to be === { :HOSTS => { :"pe-ubuntu-lucid" => { :roles => %w[agent dashboard database master], :vmname => "pe-ubuntu-lucid", :platform => "ubuntu-10.04-i386", :snapshot => "clean-w-keys", :hypervisor => "fusion" }, :"pe-centos6" => { :roles => ["agent"], :vmname => "pe-centos6", :platform => "el-6-i386", :hypervisor => "fusion", :snapshot => "clean-w-keys" } }, :nfs_server => "none", :consoleport => 443 }
16
15
  end
17
16
 
18
17
  it "can merge CONFIG section into overall hash" do
@@ -24,60 +23,59 @@ module Beaker
24
23
 
25
24
  it "returns empty configuration when no file provided" do
26
25
  FakeFS.deactivate!
27
- expect(parser.parse_hosts_file()).to be === { :HOSTS => {} }
26
+ expect(parser.parse_hosts_file).to be === { :HOSTS => {} }
28
27
  end
29
28
 
30
29
  it "raises an error on no file found" do
31
30
  FakeFS.deactivate!
32
- expect{parser.parse_hosts_file("not a valid path")}.to raise_error(/is not a valid path/)
31
+ expect { parser.parse_hosts_file("not a valid path") }.to raise_error(/is not a valid path/)
33
32
  end
34
33
 
35
34
  it "raises an error on bad yaml file" do
36
35
  FakeFS.deactivate!
37
- expect( File ).to receive(:exist?).and_return(true)
36
+ expect(File).to receive(:exist?).and_return(true)
38
37
 
39
38
  expect { parser.parse_hosts_file("not a valid path") }.to raise_error(Errno::ENOENT)
40
39
  end
41
40
 
42
41
  it 'returns a #new_host_options hash if given no arguments' do
43
42
  host_options = parser.parse_hosts_file
44
- expect( host_options ).to be === parser.new_host_options
43
+ expect(host_options).to be === parser.new_host_options
45
44
  end
46
45
 
47
46
  it 'passes a YAML.load call through to #merge_hosts_yaml' do
48
47
  yaml_string = 'not actually yaml, but that wont matter'
49
- expect( File ).to receive( :exist?).and_return(true)
50
- expect( File ).to receive( :read ).and_return(yaml_string)
51
- parser.parse_hosts_file( yaml_string )
48
+ expect(File).to receive(:exist?).and_return(true)
49
+ expect(File).to receive(:read).and_return(yaml_string)
50
+ parser.parse_hosts_file(yaml_string)
52
51
  end
53
52
 
54
53
  it 'processes ERB in the host YAML successfully' do
55
54
  yaml_string = '1 plus 2: <%= 1 + 2 %>'
56
- expect( File ).to receive( :exist?).and_return(true)
57
- expect( File ).to receive( :read ).and_return(yaml_string)
58
- beaker_options_hash = parser.parse_hosts_file( yaml_string )
55
+ expect(File).to receive(:exist?).and_return(true)
56
+ expect(File).to receive(:read).and_return(yaml_string)
57
+ beaker_options_hash = parser.parse_hosts_file(yaml_string)
59
58
  expect(beaker_options_hash['1 plus 2']).to eq(3)
60
59
  end
61
60
 
62
61
  it "can correctly read a hosts_preserved.yml file" do
63
62
  FakeFS.deactivate!
64
- expect{ parser.parse_hosts_file(filepath_yaml) }.not_to raise_error
63
+ expect { parser.parse_hosts_file(filepath_yaml) }.not_to raise_error
65
64
  expect(parser.parse_hosts_file(filepath_yaml).dig(:HOSTS, :"primary.host")).not_to be_nil
66
65
  end
67
66
  end
68
67
 
69
68
  describe '#parse_hosts_string' do
70
-
71
69
  it 'will return a #new_host_options hash if given no arguments' do
72
70
  host_options = parser.parse_hosts_string
73
- expect( host_options ).to be === parser.new_host_options
71
+ expect(host_options).to be === parser.new_host_options
74
72
  end
75
73
 
76
74
  it 'passes a process_yaml call through to #merge_hosts_yaml' do
77
75
  yaml_string = 'not actually yaml, but that wont matter'
78
76
  expect(described_class).to receive(:process_yaml).with(yaml_string, instance_of(Binding))
79
77
 
80
- parser.parse_hosts_string( yaml_string )
78
+ parser.parse_hosts_string(yaml_string)
81
79
  end
82
80
  end
83
81
 
@@ -86,29 +84,29 @@ module Beaker
86
84
  host_options = {}
87
85
  yield_to_merge = { :pants => 'truth to the face' }
88
86
  block_count = 0
89
- answer = parser.merge_hosts_yaml( host_options, 'err_msg' ) {
87
+ answer = parser.merge_hosts_yaml(host_options, 'err_msg') do
90
88
  block_count += 1
91
89
  yield_to_merge
92
- }
90
+ end
93
91
 
94
- expect( block_count ).to be === 1
95
- expect( answer ).to be === host_options.merge( yield_to_merge )
92
+ expect(block_count).to be === 1
93
+ expect(answer).to be === host_options.merge(yield_to_merge)
96
94
  end
97
95
 
98
96
  class MockSyntaxError < Psych::SyntaxError
99
97
  def initialize
100
- super( '', 0, 0, 0, '', '' )
98
+ super('', 0, 0, 0, '', '')
101
99
  end
102
100
  end
103
101
 
104
102
  it 'raises an ArgumentError if can\'t process YAML' do
105
103
  # allow( parser ).to receive( :merge_hosts_yaml )
106
104
  err_value = 'err_msg8797'
107
- expect {
108
- parser.merge_hosts_yaml( {}, err_value ) {
105
+ expect do
106
+ parser.merge_hosts_yaml({}, err_value) do
109
107
  raise MockSyntaxError
110
- }
111
- }.to raise_error( ArgumentError, /#{err_value}/ )
108
+ end
109
+ end.to raise_error(ArgumentError, /#{err_value}/)
112
110
  end
113
111
  end
114
112
 
@@ -116,13 +114,13 @@ module Beaker
116
114
  it 'adds a roles array to a host if not present' do
117
115
  host_options = { 'HOSTS' => {
118
116
  'host1' => {},
119
- 'host2' => {}
120
- }}
117
+ 'host2' => {},
118
+ } }
121
119
 
122
- parser.fix_roles_array( host_options )
120
+ parser.fix_roles_array(host_options)
123
121
 
124
122
  host_options['HOSTS'].each do |_host_name, host_hash|
125
- expect( host_hash['roles'] ).to be === []
123
+ expect(host_hash['roles']).to be === []
126
124
  end
127
125
  end
128
126
  end
@@ -3,21 +3,18 @@ require "spec_helper"
3
3
  module Beaker
4
4
  module Options
5
5
  describe OptionsFileParser do
6
-
7
- let(:parser) {described_class}
8
- let(:simple_opts) {File.join(File.expand_path(File.dirname(__FILE__)), "data", "opts.txt")}
6
+ let(:parser) { described_class }
7
+ let(:simple_opts) { File.join(__dir__, "data", "opts.txt") }
9
8
 
10
9
  it "can correctly read options from a file" do
11
10
  FakeFS.deactivate!
12
- expect(parser.parse_options_file(simple_opts)).to be === {:debug=>true, :tests=>"test.rb", :pre_suite=>["pre-suite.rb"], :post_suite=>"post_suite1.rb,post_suite2.rb"}
11
+ expect(parser.parse_options_file(simple_opts)).to be === { :debug => true, :tests => "test.rb", :pre_suite => ["pre-suite.rb"], :post_suite => "post_suite1.rb,post_suite2.rb" }
13
12
  end
14
13
 
15
14
  it "raises an error on no file found" do
16
15
  FakeFS.deactivate!
17
- expect{parser.parse_options_file("not a valid path")}.to raise_error(ArgumentError)
16
+ expect { parser.parse_options_file("not a valid path") }.to raise_error(ArgumentError)
18
17
  end
19
-
20
-
21
18
  end
22
19
  end
23
20
  end
@@ -3,8 +3,7 @@ require "spec_helper"
3
3
  module Beaker
4
4
  module Options
5
5
  describe OptionsHash do
6
- let(:options) { described_class.new }
7
-
6
+ let(:options) { described_class.new }
8
7
 
9
8
  it "supports is_pe?, defaults to pe" do
10
9
  expect(options).to be_is_pe
@@ -19,21 +18,20 @@ module Beaker
19
18
  let(:options) { described_class.new }
20
19
 
21
20
  it 'returns pe as expected in the normal case' do
22
- newhash = options.merge({:type => 'pe'})
21
+ newhash = options.merge({ :type => 'pe' })
23
22
  expect(newhash.get_type).to be === :pe
24
23
  end
25
24
 
26
25
  it 'returns foss as expected in the normal case' do
27
- newhash = options.merge({:type => 'foss'})
26
+ newhash = options.merge({ :type => 'foss' })
28
27
  expect(newhash.get_type).to be === :foss
29
28
  end
30
29
 
31
30
  it 'returns foss as the default' do
32
- newhash = options.merge({:type => 'git'})
31
+ newhash = options.merge({ :type => 'git' })
33
32
  expect(newhash.get_type).to be === :foss
34
33
  end
35
34
  end
36
35
  end
37
-
38
36
  end
39
37
  end