beaker 4.40.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +13 -11
  8. data/Gemfile +12 -7
  9. data/Rakefile +99 -111
  10. data/acceptance/config/acceptance-options.rb +1 -1
  11. data/acceptance/config/base/acceptance-options.rb +2 -2
  12. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  13. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  14. data/acceptance/fixtures/module/Rakefile +1 -1
  15. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  16. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  17. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  18. data/acceptance/lib/helpers/test_helper.rb +4 -3
  19. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  20. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  21. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  40. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  41. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  42. data/acceptance/tests/base/host/file_test.rb +2 -2
  43. data/acceptance/tests/base/host/group_test.rb +0 -1
  44. data/acceptance/tests/base/host/host_test.rb +66 -63
  45. data/acceptance/tests/base/host/packages.rb +1 -2
  46. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  47. data/acceptance/tests/base/host/user_test.rb +0 -1
  48. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  49. data/acceptance/tests/base/test_suite/export.rb +6 -9
  50. data/acceptance/tests/install/from_file.rb +2 -4
  51. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  52. data/acceptance/tests/subcommands/destroy.rb +19 -21
  53. data/acceptance/tests/subcommands/exec.rb +0 -1
  54. data/acceptance/tests/subcommands/init.rb +2 -3
  55. data/acceptance/tests/subcommands/provision.rb +0 -1
  56. data/beaker.gemspec +4 -7
  57. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  58. data/docs/how_to/debug_beaker_tests.md +12 -12
  59. data/docs/how_to/hosts/eos.md +2 -12
  60. data/docs/how_to/install_puppet.md +0 -18
  61. data/docs/how_to/the_beaker_dsl.md +0 -2
  62. data/lib/beaker/cli.rb +59 -68
  63. data/lib/beaker/command.rb +20 -28
  64. data/lib/beaker/command_factory.rb +3 -2
  65. data/lib/beaker/dsl/assertions.rb +6 -18
  66. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  67. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  68. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  69. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  70. data/lib/beaker/dsl/helpers.rb +2 -4
  71. data/lib/beaker/dsl/outcomes.rb +13 -15
  72. data/lib/beaker/dsl/patterns.rb +1 -3
  73. data/lib/beaker/dsl/roles.rb +17 -20
  74. data/lib/beaker/dsl/structure.rb +53 -65
  75. data/lib/beaker/dsl/test_tagging.rb +7 -10
  76. data/lib/beaker/dsl/wrappers.rb +15 -16
  77. data/lib/beaker/dsl.rb +2 -3
  78. data/lib/beaker/host/aix/exec.rb +1 -1
  79. data/lib/beaker/host/aix/file.rb +0 -1
  80. data/lib/beaker/host/aix/group.rb +1 -1
  81. data/lib/beaker/host/aix/user.rb +1 -1
  82. data/lib/beaker/host/aix.rb +3 -4
  83. data/lib/beaker/host/cisco.rb +27 -39
  84. data/lib/beaker/host/eos.rb +4 -30
  85. data/lib/beaker/host/freebsd/exec.rb +1 -1
  86. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  87. data/lib/beaker/host/freebsd.rb +9 -12
  88. data/lib/beaker/host/mac/exec.rb +4 -4
  89. data/lib/beaker/host/mac/group.rb +7 -7
  90. data/lib/beaker/host/mac/pkg.rb +3 -106
  91. data/lib/beaker/host/mac/user.rb +2 -2
  92. data/lib/beaker/host/mac.rb +8 -9
  93. data/lib/beaker/host/pswindows/exec.rb +66 -70
  94. data/lib/beaker/host/pswindows/file.rb +3 -5
  95. data/lib/beaker/host/pswindows/group.rb +3 -3
  96. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  97. data/lib/beaker/host/pswindows/user.rb +3 -3
  98. data/lib/beaker/host/pswindows.rb +4 -3
  99. data/lib/beaker/host/unix/exec.rb +80 -82
  100. data/lib/beaker/host/unix/file.rb +38 -43
  101. data/lib/beaker/host/unix/group.rb +1 -1
  102. data/lib/beaker/host/unix/pkg.rb +154 -417
  103. data/lib/beaker/host/unix/user.rb +2 -2
  104. data/lib/beaker/host/unix.rb +8 -11
  105. data/lib/beaker/host/windows/exec.rb +17 -17
  106. data/lib/beaker/host/windows/file.rb +3 -3
  107. data/lib/beaker/host/windows/group.rb +3 -3
  108. data/lib/beaker/host/windows/pkg.rb +3 -54
  109. data/lib/beaker/host/windows/user.rb +3 -3
  110. data/lib/beaker/host/windows.rb +12 -12
  111. data/lib/beaker/host.rb +76 -133
  112. data/lib/beaker/host_prebuilt_steps.rb +93 -198
  113. data/lib/beaker/hypervisor/noop.rb +2 -4
  114. data/lib/beaker/hypervisor.rb +44 -61
  115. data/lib/beaker/local_connection.rb +2 -4
  116. data/lib/beaker/logger.rb +68 -76
  117. data/lib/beaker/logger_junit.rb +21 -25
  118. data/lib/beaker/network_manager.rb +39 -42
  119. data/lib/beaker/options/command_line_parser.rb +12 -23
  120. data/lib/beaker/options/hosts_file_parser.rb +16 -24
  121. data/lib/beaker/options/options_file_parser.rb +3 -6
  122. data/lib/beaker/options/options_hash.rb +2 -7
  123. data/lib/beaker/options/parser.rb +86 -102
  124. data/lib/beaker/options/presets.rb +114 -123
  125. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  126. data/lib/beaker/options/validator.rb +26 -31
  127. data/lib/beaker/perf.rb +22 -27
  128. data/lib/beaker/platform.rb +38 -46
  129. data/lib/beaker/result.rb +7 -6
  130. data/lib/beaker/shared/error_handler.rb +8 -10
  131. data/lib/beaker/shared/fog_credentials.rb +5 -9
  132. data/lib/beaker/shared/host_manager.rb +36 -41
  133. data/lib/beaker/shared/options_resolver.rb +3 -7
  134. data/lib/beaker/shared/repetition.rb +2 -4
  135. data/lib/beaker/shared/semvar.rb +37 -41
  136. data/lib/beaker/shared/timed.rb +0 -3
  137. data/lib/beaker/shared.rb +1 -1
  138. data/lib/beaker/ssh_connection.rb +38 -47
  139. data/lib/beaker/subcommand.rb +17 -24
  140. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  141. data/lib/beaker/tasks/quick_start.rb +4 -9
  142. data/lib/beaker/tasks/rake_task.rb +25 -27
  143. data/lib/beaker/tasks/test.rb +4 -4
  144. data/lib/beaker/test_case.rb +15 -27
  145. data/lib/beaker/test_suite.rb +35 -39
  146. data/lib/beaker/test_suite_result.rb +45 -47
  147. data/lib/beaker/version.rb +1 -1
  148. data/lib/beaker.rb +5 -6
  149. data/spec/beaker/cli_spec.rb +121 -142
  150. data/spec/beaker/command_spec.rb +55 -59
  151. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  152. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  153. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  154. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  155. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  156. data/spec/beaker/dsl/roles_spec.rb +125 -130
  157. data/spec/beaker/dsl/structure_spec.rb +169 -158
  158. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  159. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  160. data/spec/beaker/host/aix_spec.rb +14 -14
  161. data/spec/beaker/host/cisco_spec.rb +84 -94
  162. data/spec/beaker/host/eos_spec.rb +15 -36
  163. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  164. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  165. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  166. data/spec/beaker/host/mac/group_spec.rb +47 -56
  167. data/spec/beaker/host/mac/user_spec.rb +53 -62
  168. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  169. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  170. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  171. data/spec/beaker/host/pswindows_spec.rb +13 -13
  172. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  173. data/spec/beaker/host/unix/file_spec.rb +66 -73
  174. data/spec/beaker/host/unix/pkg_spec.rb +155 -401
  175. data/spec/beaker/host/unix_spec.rb +11 -207
  176. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  177. data/spec/beaker/host/windows/file_spec.rb +18 -19
  178. data/spec/beaker/host/windows/group_spec.rb +10 -12
  179. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  180. data/spec/beaker/host/windows/user_spec.rb +17 -23
  181. data/spec/beaker/host/windows_spec.rb +39 -39
  182. data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
  183. data/spec/beaker/host_spec.rb +204 -284
  184. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  185. data/spec/beaker/localhost_connection_spec.rb +10 -11
  186. data/spec/beaker/logger_junit_spec.rb +19 -30
  187. data/spec/beaker/logger_spec.rb +153 -136
  188. data/spec/beaker/network_manager_spec.rb +23 -23
  189. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  190. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  191. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  192. data/spec/beaker/options/options_hash_spec.rb +4 -6
  193. data/spec/beaker/options/parser_spec.rb +167 -167
  194. data/spec/beaker/options/presets_spec.rb +7 -9
  195. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  196. data/spec/beaker/options/validator_spec.rb +10 -11
  197. data/spec/beaker/perf_spec.rb +18 -21
  198. data/spec/beaker/platform_spec.rb +25 -36
  199. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  200. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  201. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  202. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  203. data/spec/beaker/shared/repetition_spec.rb +17 -24
  204. data/spec/beaker/shared/semvar_spec.rb +21 -26
  205. data/spec/beaker/ssh_connection_spec.rb +76 -83
  206. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  207. data/spec/beaker/subcommand_spec.rb +75 -77
  208. data/spec/beaker/test_case_spec.rb +25 -50
  209. data/spec/beaker/test_suite_spec.rb +147 -154
  210. data/spec/helpers.rb +48 -53
  211. data/spec/matchers.rb +8 -7
  212. data/spec/mocks.rb +1 -6
  213. data/spec/spec_helper.rb +0 -1
  214. metadata +7 -24
  215. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  216. data/acceptance/tests/base/external_resources_test.rb +0 -31
  217. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -1,50 +1,47 @@
1
- # encoding: UTF-8
2
1
  require 'spec_helper'
3
2
 
4
3
  module Beaker
5
4
  describe Logger do
6
5
  let(:my_io) { StringIO.new }
7
- let(:logger) { described_class.new(my_io, :quiet => true) }
8
- let(:basic_logger) { described_class.new(:quiet => true) }
9
- let(:test_dir) { 'tmp/tests' }
6
+ let(:logger) { described_class.new(my_io, :quiet => true) }
7
+ let(:basic_logger) { described_class.new(:quiet => true) }
8
+ let(:test_dir) { 'tmp/tests' }
10
9
  let(:dummy_prefix) { 'dummy' }
11
10
 
12
11
  describe '#convert' do
13
12
  let(:valid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\n" }
14
- let(:invalid_utf8) {"/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n"}
13
+ let(:invalid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n" }
15
14
 
16
15
  it 'preserves valid utf-8 strings' do
17
- expect( logger.convert(valid_utf8) ).to be === valid_utf8
16
+ expect(logger.convert(valid_utf8)).to be === valid_utf8
18
17
  end
19
18
 
20
19
  it 'strips out invalid utf-8 characters' do
21
- expect( logger.convert(invalid_utf8) ).to be === valid_utf8
20
+ expect(logger.convert(invalid_utf8)).to be === valid_utf8
22
21
  end
23
22
 
24
23
  it 'supports frozen strings' do
25
24
  valid_utf8.freeze
26
- expect( logger.convert(valid_utf8) ).to be === valid_utf8
25
+ expect(logger.convert(valid_utf8)).to be === valid_utf8
27
26
  end
28
27
  end
29
28
 
30
29
  describe '#generate_dated_log_folder' do
31
-
32
30
  it 'generates path for a given timestamp' do
33
31
  input_time = Time.new(2014, 6, 2, 16, 31, 22, '-07:00')
34
- expect( described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time) ).to be === File.join(test_dir, dummy_prefix, '2014-06-02_16_31_22')
32
+ expect(described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)).to be === File.join(test_dir, dummy_prefix, '2014-06-02_16_31_22')
35
33
  end
36
34
 
37
35
  it 'generates directory for a given timestamp' do
38
36
  input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
39
- expect( File ).to be_directory described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)
37
+ expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)
40
38
  end
41
39
 
42
40
  it 'generates nested directories if given as a log_prefix' do
43
41
  input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
44
42
  prefix = 'a/man/a/plan/a/canal/panama'
45
- expect( File ).to be_directory described_class.generate_dated_log_folder(test_dir, prefix, input_time)
43
+ expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, prefix, input_time)
46
44
  end
47
-
48
45
  end
49
46
 
50
47
  describe '#prefix_log_line' do
@@ -59,7 +56,7 @@ module Beaker
59
56
 
60
57
  def prefix_log_line_test_compare_helper(in_test, out_answer)
61
58
  logger.with_indent do
62
- expect( logger.prefix_log_line(in_test) ).to be === out_answer
59
+ expect(logger.prefix_log_line(in_test)).to be === out_answer
63
60
  end
64
61
  end
65
62
 
@@ -93,7 +90,7 @@ module Beaker
93
90
  logger.with_indent do
94
91
  logger.with_indent do
95
92
  logger.with_indent do
96
- expect( logger.prefix_log_line(line_arg) ).to be === answer
93
+ expect(logger.prefix_log_line(line_arg)).to be === answer
97
94
  end
98
95
  end
99
96
  end
@@ -112,30 +109,30 @@ module Beaker
112
109
 
113
110
  it 'steps in correctly (simple case)' do
114
111
  logger.with_indent do
115
- expect( logger.line_prefix ).to be === ' '
112
+ expect(logger.line_prefix).to be === ' '
116
113
  end
117
114
  end
118
115
 
119
- it 'sets length correctly in mixed scenario ' do
116
+ it 'sets length correctly in mixed scenario' do
120
117
  logger.with_indent do
121
118
  logger.with_indent {}
122
119
  logger.with_indent do
123
120
  logger.with_indent {}
124
- expect( logger.line_prefix ).to be === ' '
121
+ expect(logger.line_prefix).to be === ' '
125
122
  end
126
123
  end
127
124
  end
128
125
 
129
126
  it 'can handle arbitrary strings as prefixes' do
130
127
  logger.line_prefix = 'Some string:'
131
- expect( logger.line_prefix ).to be === 'Some string:'
128
+ expect(logger.line_prefix).to be === 'Some string:'
132
129
  end
133
130
 
134
131
  it 'can handle stepping in with arbitrary strings' do
135
132
  logger.line_prefix = 'Some string:'
136
133
  logger.with_indent do
137
134
  logger.with_indent do
138
- expect( logger.line_prefix ).to be === 'Some string: '
135
+ expect(logger.line_prefix).to be === 'Some string: '
139
136
  end
140
137
  end
141
138
  end
@@ -143,7 +140,7 @@ module Beaker
143
140
  it 'can handle stepping in and out with arbitrary strings' do
144
141
  logger.line_prefix = 'Some string:'
145
142
  10.times { logger.with_indent {} }
146
- expect( logger.line_prefix ).to be === 'Some string:'
143
+ expect(logger.line_prefix).to be === 'Some string:'
147
144
  end
148
145
 
149
146
  it 'restores the original prefix if an argument is raised' do
@@ -160,17 +157,21 @@ module Beaker
160
157
  context 'new' do
161
158
  it 'does not duplicate STDOUT when directly passed to it' do
162
159
  stdout_logger = described_class.new STDOUT
163
- expect( stdout_logger.destinations.size ).to be === 1
160
+ expect(stdout_logger.destinations.size).to be === 1
164
161
  end
165
162
 
166
163
  context 'default for' do
167
- its(:destinations) { is_expected.to include(STDOUT) }
168
- its(:color) { is_expected.to be_nil }
169
- its(:log_level) { is_expected.to be :verbose }
164
+ it do
165
+ expect(subject).to have_attributes(
166
+ destinations: include(STDOUT),
167
+ color: be_nil,
168
+ log_level: :verbose,
169
+ )
170
+ end
170
171
  end
171
172
 
172
173
  context 'log_colors' do
173
- original_build_number = ENV['BUILD_NUMBER']
174
+ original_build_number = ENV.fetch('BUILD_NUMBER', nil)
174
175
 
175
176
  before do
176
177
  ENV['BUILD_NUMBER'] = nil
@@ -180,29 +181,28 @@ module Beaker
180
181
  ENV['BUILD_NUMER'] = original_build_number
181
182
  end
182
183
 
183
-
184
184
  it 'has the default log_colors' do
185
185
  expect(logger.log_colors).to be == {
186
- :error=> Beaker::Logger::RED,
187
- :warn=> Beaker::Logger::BRIGHT_RED,
188
- :success=> Beaker::Logger::MAGENTA,
189
- :notify=> Beaker::Logger::BLUE,
190
- :info=> Beaker::Logger::GREEN,
191
- :debug=> Beaker::Logger::WHITE,
192
- :trace=> Beaker::Logger::BRIGHT_YELLOW,
193
- :perf=> Beaker::Logger::BRIGHT_MAGENTA,
194
- :host=> Beaker::Logger::YELLOW
186
+ :error => Beaker::Logger::RED,
187
+ :warn => Beaker::Logger::BRIGHT_RED,
188
+ :success => Beaker::Logger::MAGENTA,
189
+ :notify => Beaker::Logger::BLUE,
190
+ :info => Beaker::Logger::GREEN,
191
+ :debug => Beaker::Logger::WHITE,
192
+ :trace => Beaker::Logger::BRIGHT_YELLOW,
193
+ :perf => Beaker::Logger::BRIGHT_MAGENTA,
194
+ :host => Beaker::Logger::YELLOW,
195
195
  }
196
196
  end
197
197
 
198
198
  context 'when passing in log_color options' do
199
- let(:log_colors) {
199
+ let(:log_colors) do
200
200
  {
201
- :error => "\e[00;30m"
201
+ :error => "\e[00;30m",
202
202
  }
203
- }
203
+ end
204
204
 
205
- let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
205
+ let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
206
206
 
207
207
  it 'overrides the specified log colors' do
208
208
  expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
@@ -229,13 +229,13 @@ module Beaker
229
229
  end
230
230
 
231
231
  context 'when overriding default log colors' do
232
- let(:log_colors) {
232
+ let(:log_colors) do
233
233
  {
234
- :error => "\e[00;30m"
234
+ :error => "\e[00;30m",
235
235
  }
236
- }
236
+ end
237
237
 
238
- let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
238
+ let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
239
239
 
240
240
  it 'overrides the specified log colors' do
241
241
  expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
@@ -256,10 +256,10 @@ module Beaker
256
256
  context 'it can' do
257
257
  it 'open/create a file when a string is given to add_destination' do
258
258
  logger.add_destination 'my_tmp_file'
259
- expect( File ).to exist( 'my_tmp_file' )
259
+ expect(File).to exist('my_tmp_file')
260
260
 
261
- io = logger.destinations.find {|d| d.respond_to? :path }
262
- expect( io.path ).to match(/my_tmp_file/)
261
+ io = logger.destinations.find { |d| d.respond_to? :path }
262
+ expect(io.path).to match(/my_tmp_file/)
263
263
  end
264
264
 
265
265
  it 'remove destinations with the remove_destinations method' do
@@ -268,174 +268,191 @@ module Beaker
268
268
  logger.remove_destination my_io
269
269
  logger.remove_destination 'my_file'
270
270
 
271
- expect( logger.destinations ).to be_empty
271
+ expect(logger.destinations).to be_empty
272
272
  end
273
273
 
274
274
  it 'strip colors from arrays of input' do
275
- stripped = logger.strip_colors_from [ "\e[00;30m text! \e[00;00m" ]
276
- expect( stripped ).to be === [ ' text! ' ]
275
+ stripped = logger.strip_colors_from ["\e[00;30m text! \e[00;00m"]
276
+ expect(stripped).to be === [' text! ']
277
277
  end
278
278
 
279
279
  it 'colors strings if @color is set' do
280
280
  colorized_logger = described_class.new my_io, :color => true, :quiet => true
281
281
 
282
- expect( my_io ).to receive( :print ).with "\e[00;30m"
283
- expect( my_io ).to receive( :print )
284
- expect( my_io ).to receive( :puts ).with 'my string'
282
+ expect(my_io).to receive(:print).with "\e[00;30m"
283
+ expect(my_io).to receive(:print)
284
+ expect(my_io).to receive(:puts).with 'my string'
285
285
 
286
286
  colorized_logger.optionally_color "\e[00;30m", 'my string'
287
287
  end
288
288
 
289
289
  context 'at trace log_level' do
290
- subject( :trace_logger ) { described_class.new( my_io,
291
- :log_level => 'trace',
292
- :quiet => true,
293
- :color => true )
294
- }
290
+ subject(:trace_logger) do
291
+ described_class.new(my_io,
292
+ :log_level => 'trace',
293
+ :quiet => true,
294
+ :color => true)
295
+ end
295
296
 
296
- its( :is_debug? ) { is_expected.to be_truthy }
297
- its( :is_trace? ) { is_expected.to be_truthy }
298
- its( :is_warn? ) { is_expected.to be_truthy }
297
+ it do
298
+ expect(subject).to have_attributes(
299
+ :is_debug? => be_truthy,
300
+ :is_trace? => be_truthy,
301
+ :is_warn? => be_truthy,
302
+ )
303
+ end
299
304
 
300
305
  context 'but print' do
301
306
  before do
302
- allow( my_io ).to receive :puts
303
- expect( my_io ).to receive( :print ).at_least :twice
307
+ allow(my_io).to receive :puts
308
+ expect(my_io).to receive(:print).at_least :twice
304
309
  end
305
310
 
306
- it( 'warnings' ) { trace_logger.warn 'IMA WARNING!' }
307
- it( 'successes' ) { trace_logger.success 'SUCCESS!' }
308
- it( 'errors' ) { trace_logger.error 'ERROR!' }
309
- it( 'host_output' ) { trace_logger.host_output 'ERROR!' }
310
- it( 'debugs' ) { trace_logger.debug 'DEBUGGING!' }
311
- it( 'traces' ) { trace_logger.trace 'TRACING!' }
311
+ it('warnings') { trace_logger.warn 'IMA WARNING!' }
312
+ it('successes') { trace_logger.success 'SUCCESS!' }
313
+ it('errors') { trace_logger.error 'ERROR!' }
314
+ it('host_output') { trace_logger.host_output 'ERROR!' }
315
+ it('debugs') { trace_logger.debug 'DEBUGGING!' }
316
+ it('traces') { trace_logger.trace 'TRACING!' }
312
317
  end
313
318
  end
314
319
 
315
320
  context 'at verbose log_level' do
316
- subject( :verbose_logger ) { described_class.new( my_io,
317
- :log_level => 'verbose',
318
- :quiet => true,
319
- :color => true )
320
- }
321
+ subject(:verbose_logger) do
322
+ described_class.new(my_io,
323
+ :log_level => 'verbose',
324
+ :quiet => true,
325
+ :color => true)
326
+ end
321
327
 
322
- its( :is_trace? ) { is_expected.to be_falsy }
323
- its( :is_debug? ) { is_expected.to be_falsy }
324
- its( :is_verbose? ) { is_expected.to be_truthy }
325
- its( :is_warn? ) { is_expected.to be_truthy }
328
+ it do
329
+ expect(subject).to have_attributes(
330
+ :is_trace? => be_falsy,
331
+ :is_debug? => be_falsy,
332
+ :is_verbose? => be_truthy,
333
+ :is_warn? => be_truthy,
334
+ )
335
+ end
326
336
 
327
337
  context 'but print' do
328
338
  before do
329
- allow( my_io ).to receive :puts
330
- expect( my_io ).to receive( :print ).at_least :twice
339
+ allow(my_io).to receive :puts
340
+ expect(my_io).to receive(:print).at_least :twice
331
341
  end
332
342
 
333
- it( 'warnings' ) { verbose_logger.warn 'IMA WARNING!' }
334
- it( 'successes' ) { verbose_logger.success 'SUCCESS!' }
335
- it( 'errors' ) { verbose_logger.error 'ERROR!' }
336
- it( 'host_output' ) { verbose_logger.host_output 'ERROR!' }
337
- it( 'debugs' ) { verbose_logger.debug 'NOT DEBUGGING!' }
343
+ it('warnings') { verbose_logger.warn 'IMA WARNING!' }
344
+ it('successes') { verbose_logger.success 'SUCCESS!' }
345
+ it('errors') { verbose_logger.error 'ERROR!' }
346
+ it('host_output') { verbose_logger.host_output 'ERROR!' }
347
+ it('debugs') { verbose_logger.debug 'NOT DEBUGGING!' }
338
348
  end
339
349
  end
340
350
 
341
351
  context 'at debug log_level' do
342
- subject( :debug_logger ) { described_class.new( my_io,
343
- :log_level => 'debug',
344
- :quiet => true,
345
- :color => true )
346
- }
352
+ subject(:debug_logger) do
353
+ described_class.new(my_io,
354
+ :log_level => 'debug',
355
+ :quiet => true,
356
+ :color => true)
357
+ end
347
358
 
348
- its( :is_trace? ) { is_expected.to be_falsy }
349
- its( :is_debug? ) { is_expected.to be_truthy }
350
- its( :is_warn? ) { is_expected.to be_truthy }
359
+ it do
360
+ expect(subject).to have_attributes(
361
+ :is_trace? => be_falsy,
362
+ :is_debug? => be_truthy,
363
+ :is_warn? => be_truthy,
364
+ )
365
+ end
351
366
 
352
367
  context 'successfully print' do
353
368
  before do
354
- allow( my_io ).to receive :puts
355
- expect( my_io ).to receive( :print ).at_least :twice
369
+ allow(my_io).to receive :puts
370
+ expect(my_io).to receive(:print).at_least :twice
356
371
  end
357
372
 
358
- it( 'warnings' ) { debug_logger.warn 'IMA WARNING!' }
359
- it( 'debugs' ) { debug_logger.debug 'IMA DEBUGGING!' }
360
- it( 'successes' ) { debug_logger.success 'SUCCESS!' }
361
- it( 'errors' ) { debug_logger.error 'ERROR!' }
362
- it( 'host_output' ) { debug_logger.host_output 'ERROR!' }
373
+ it('warnings') { debug_logger.warn 'IMA WARNING!' }
374
+ it('debugs') { debug_logger.debug 'IMA DEBUGGING!' }
375
+ it('successes') { debug_logger.success 'SUCCESS!' }
376
+ it('errors') { debug_logger.error 'ERROR!' }
377
+ it('host_output') { debug_logger.host_output 'ERROR!' }
363
378
  end
364
379
  end
365
380
 
366
381
  context 'at info log_level' do
367
- subject( :info_logger ) { described_class.new( my_io,
368
- :log_level => :info,
369
- :quiet => true,
370
- :color => true )
371
- }
372
-
373
- its( :is_debug? ) { is_expected.to be_falsy }
374
- its( :is_trace? ) { is_expected.to be_falsy }
382
+ subject(:info_logger) do
383
+ described_class.new(my_io,
384
+ :log_level => :info,
385
+ :quiet => true,
386
+ :color => true)
387
+ end
375
388
 
389
+ it do
390
+ expect(subject).to have_attributes(
391
+ :is_debug? => be_falsy,
392
+ :is_trace? => be_falsy,
393
+ )
394
+ end
376
395
 
377
396
  context 'skip' do
378
397
  before do
379
- expect( my_io ).not_to receive :puts
380
- expect( my_io ).not_to receive :print
398
+ expect(my_io).not_to receive :puts
399
+ expect(my_io).not_to receive :print
381
400
  end
382
401
 
383
- it( 'debugs' ) { info_logger.debug 'NOT DEBUGGING!' }
384
- it( 'traces' ) { info_logger.debug 'NOT TRACING!' }
402
+ it('debugs') { info_logger.debug 'NOT DEBUGGING!' }
403
+ it('traces') { info_logger.debug 'NOT TRACING!' }
385
404
  end
386
405
 
387
-
388
406
  context 'but print' do
389
407
  before do
390
- expect( my_io ).to receive :puts
391
- expect( my_io ).to receive( :print ).twice
408
+ expect(my_io).to receive :puts
409
+ expect(my_io).to receive(:print).twice
392
410
  end
393
411
 
394
- it( 'successes' ) { info_logger.success 'SUCCESS!' }
395
- it( 'notifications' ) { info_logger.notify 'NOTFIY!' }
396
- it( 'errors' ) { info_logger.error 'ERROR!' }
412
+ it('successes') { info_logger.success 'SUCCESS!' }
413
+ it('notifications') { info_logger.notify 'NOTFIY!' }
414
+ it('errors') { info_logger.error 'ERROR!' }
397
415
  end
398
416
  end
399
417
 
400
418
  context 'SUT output logging' do
401
-
402
419
  context 'host output logging' do
403
- subject( :host_output ) { described_class.new( my_io,
404
- :log_level => :verbose,
405
- :quiet => true,
406
- :color => true )}
420
+ subject(:host_output) do
421
+ described_class.new(my_io,
422
+ :log_level => :verbose,
423
+ :quiet => true,
424
+ :color => true)
425
+ end
407
426
 
408
427
  it 'outputs GREY when @color is set to true' do
409
428
  colorized_logger = host_output
410
429
 
411
- expect( my_io ).to receive( :print ).with "\e[01;30m"
412
- expect( my_io ).to receive( :print )
413
- expect( my_io ).to receive( :puts ).with 'my string'
430
+ expect(my_io).to receive(:print).with "\e[01;30m"
431
+ expect(my_io).to receive(:print)
432
+ expect(my_io).to receive(:puts).with 'my string'
414
433
 
415
434
  colorized_logger.optionally_color "\e[01;30m", 'my string'
416
435
  end
417
-
418
436
  end
419
437
 
420
438
  context 'color host output' do
421
- subject( :color_host_output ) { described_class.new( my_io,
422
- :log_level => :verbose,
423
- :quiet => true,
424
- :color => true )}
439
+ subject(:color_host_output) do
440
+ described_class.new(my_io,
441
+ :log_level => :verbose,
442
+ :quiet => true,
443
+ :color => true)
444
+ end
425
445
 
426
446
  it 'colors host_output' do
427
447
  colorized_logger = color_host_output
428
448
 
429
- expect( my_io ).to receive( :print ).with ""
430
- expect( my_io ).to receive( :puts ).with 'my string'
449
+ expect(my_io).to receive(:print).with ""
450
+ expect(my_io).to receive(:puts).with 'my string'
431
451
 
432
452
  colorized_logger.optionally_color "", 'my string'
433
453
  end
434
-
435
454
  end
436
455
  end
437
-
438
456
  end
439
-
440
457
  end
441
458
  end
@@ -1,24 +1,24 @@
1
- # encoding: UTF-8
2
1
  require 'spec_helper'
3
2
 
4
3
  module Beaker
5
4
  describe NetworkManager do
6
- let( :mock_provisioning_logger ) {
5
+ let(:mock_provisioning_logger) do
7
6
  mock_provisioning_logger = Object.new
8
- allow( mock_provisioning_logger ).to receive( :notify )
9
- mock_provisioning_logger }
10
- let( :options ) {
7
+ allow(mock_provisioning_logger).to receive(:notify)
8
+ mock_provisioning_logger
9
+ end
10
+ let(:options) do
11
11
  make_opts.merge({
12
- 'logger' => double().as_null_object,
13
- :logger_sut => mock_provisioning_logger,
14
- :log_prefix => @log_prefix,
15
- :hosts_file => @hosts_file,
16
- :default_log_prefix => 'hello_default',
17
- })
18
- }
19
- let( :network_manager ) { described_class.new(options, options[:logger]) }
20
- let( :hosts ) { make_hosts }
21
- let( :host ) { hosts[0] }
12
+ 'logger' => double.as_null_object,
13
+ :logger_sut => mock_provisioning_logger,
14
+ :log_prefix => @log_prefix,
15
+ :hosts_file => @hosts_file,
16
+ :default_log_prefix => 'hello_default',
17
+ })
18
+ end
19
+ let(:network_manager) { described_class.new(options, options[:logger]) }
20
+ let(:hosts) { make_hosts }
21
+ let(:host) { hosts[0] }
22
22
 
23
23
  describe '#log_sut_event' do
24
24
  before do
@@ -31,33 +31,33 @@ module Beaker
31
31
  pieces = log_line.split("\t")
32
32
  hypervisor_value = host['hypervisor'] ? host['hypervisor'] : ''
33
33
  platform_value = host['platform'] ? host['platform'] : ''
34
- expect( pieces[1] ).to be === '[+]'
35
- expect( pieces[2] ).to be === hypervisor_value
36
- expect( pieces[3] ).to be === platform_value
37
- expect( pieces[4] ).to be === host.log_prefix
34
+ expect(pieces[1]).to be === '[+]'
35
+ expect(pieces[2]).to be === hypervisor_value
36
+ expect(pieces[3]).to be === platform_value
37
+ expect(pieces[4]).to be === host.log_prefix
38
38
  end
39
39
 
40
40
  it 'follows the create parameter correctly' do
41
41
  log_line = network_manager.log_sut_event host, true
42
42
  pieces = log_line.split("\t")
43
- expect( pieces[1] ).to be === '[+]'
43
+ expect(pieces[1]).to be === '[+]'
44
44
 
45
45
  log_line = network_manager.log_sut_event host, false
46
46
  pieces = log_line.split("\t")
47
- expect( pieces[1] ).to be === '[-]'
47
+ expect(pieces[1]).to be === '[-]'
48
48
  end
49
49
 
50
50
  it 'sends the log line to the provisioning logger' do
51
51
  nm = network_manager
52
52
  options[:logger_sut] = mock_provisioning_logger
53
- expect( mock_provisioning_logger ).to receive( :notify ).once
53
+ expect(mock_provisioning_logger).to receive(:notify).once
54
54
  nm.log_sut_event host, true
55
55
  end
56
56
 
57
57
  it 'throws an error if the provisioning logger hasn\'t been created yet' do
58
58
  nm = network_manager
59
59
  options.delete(:logger_sut)
60
- expect{ nm.log_sut_event(host, true) }.to raise_error(ArgumentError)
60
+ expect { nm.log_sut_event(host, true) }.to raise_error(ArgumentError)
61
61
  end
62
62
  end
63
63