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
@@ -2,115 +2,111 @@ require 'spec_helper'
2
2
 
3
3
  module Cisco
4
4
  describe Host do
5
- let(:options) { @options ? @options : {
6
- :user => 'root',
7
- } }
8
- let(:platform) {
5
+ let(:options) do
6
+ @options ? @options : {
7
+ :user => 'root',
8
+ }
9
+ end
10
+ let(:platform) do
9
11
  if @platform
10
- { :platform => Beaker::Platform.new( @platform) }
12
+ { :platform => Beaker::Platform.new(@platform) }
11
13
  else
12
- { :platform => Beaker::Platform.new( 'cisco_nexus-vers-arch-extra' ) }
14
+ { :platform => Beaker::Platform.new('cisco_nexus-vers-arch-extra') }
13
15
  end
14
- }
15
- let(:host) { make_host( 'name', options.merge(platform) ) }
16
+ end
17
+ let(:host) { make_host('name', options.merge(platform)) }
16
18
 
17
19
  describe '#prepend_commands' do
18
-
19
20
  context 'for cisco_nexus-7' do
20
-
21
21
  before do
22
22
  @platform = 'cisco_nexus-7-x86_64'
23
23
  end
24
24
 
25
25
  it 'starts with sourcing the /etc/profile script' do
26
26
  answer_correct = 'source /etc/profile;'
27
- answer_test = host.prepend_commands( 'fake_command' )
28
- expect( answer_test ).to be === answer_correct
27
+ answer_test = host.prepend_commands('fake_command')
28
+ expect(answer_test).to be === answer_correct
29
29
  end
30
30
 
31
31
  it 'uses `sudo` if not root' do
32
32
  @options = { :user => 'notroot' }
33
33
  answer_correct = "source /etc/profile; sudo -E sh -c \""
34
- answer_test = host.prepend_commands( 'fake_command' )
35
- expect( answer_test ).to be === answer_correct
34
+ answer_test = host.prepend_commands('fake_command')
35
+ expect(answer_test).to be === answer_correct
36
36
  end
37
37
 
38
38
  it 'ends with the :vrf host parameter' do
39
39
  vrf_answer = 'vrf_answer_135246'
40
40
  @options = {
41
- :vrf => vrf_answer,
41
+ :vrf => vrf_answer,
42
42
  }
43
- answer_test = host.prepend_commands( 'fake_command' )
44
- expect( answer_test ).to match( /ip netns exec #{vrf_answer}$/ )
43
+ answer_test = host.prepend_commands('fake_command')
44
+ expect(answer_test).to match(/ip netns exec #{vrf_answer}$/)
45
45
  end
46
46
 
47
47
  it 'guards against "vsh" usage (scenario we never want prefixing)' do
48
48
  answer_user_pc = 'pc_param_unchanged_13584'
49
- answer_test = host.prepend_commands( 'fake/vsh/command', answer_user_pc )
50
- expect( answer_test ).to be === answer_user_pc
49
+ answer_test = host.prepend_commands('fake/vsh/command', answer_user_pc)
50
+ expect(answer_test).to be === answer_user_pc
51
51
  end
52
52
 
53
53
  it 'guards against "ntpdate" usage (we dont want prefixing on nexus)' do
54
54
  answer_user_pc = 'user_pc_param_54321'
55
- answer_test = host.prepend_commands( 'fake/ntpdate/command', answer_user_pc )
56
- expect( answer_test ).to be === answer_user_pc
55
+ answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
56
+ expect(answer_test).to be === answer_user_pc
57
57
  end
58
58
 
59
-
60
59
  it 'retains user-specified prepend commands when adding vrf' do
61
60
  @options = {
62
- :vrf => 'fakevrf',
61
+ :vrf => 'fakevrf',
63
62
  :user => 'root',
64
63
  }
65
64
  answer_prepend_commands = 'prepend'
66
65
  answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
67
- answer_test = host.prepend_commands( 'fake_command', answer_prepend_commands )
68
- expect( answer_test ).to be === answer_correct
66
+ answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
67
+ expect(answer_test).to be === answer_correct
69
68
  end
70
69
  end
71
70
 
72
71
  context 'for cisco_ios_xr-6' do
73
-
74
72
  before do
75
73
  @platform = 'cisco_ios_xr-6-x86_64'
76
74
  end
77
75
 
78
76
  it 'starts with sourcing the /etc/profile script' do
79
77
  answer_correct = 'source /etc/profile;'
80
- answer_test = host.prepend_commands( 'fake_command' )
81
- expect( answer_test ).to be === answer_correct
78
+ answer_test = host.prepend_commands('fake_command')
79
+ expect(answer_test).to be === answer_correct
82
80
  end
83
81
 
84
82
  it 'does use the :vrf host parameter if provided' do
85
83
  @options = { :vrf => 'tpnns' }
86
- answer_test = host.prepend_commands( 'fake_command' )
87
- expect( answer_test ).to match( /ip netns exec tpnns/ )
84
+ answer_test = host.prepend_commands('fake_command')
85
+ expect(answer_test).to match(/ip netns exec tpnns/)
88
86
  end
89
87
 
90
88
  it 'does not guard "ntpdate" usage' do
91
89
  answer_user_pc = 'user_pc_param_54321'
92
90
  answer_correct = 'source /etc/profile;user_pc_param_54321'
93
- answer_test = host.prepend_commands( 'fake/ntpdate/command', answer_user_pc )
94
- expect( answer_test ).to be === answer_correct
91
+ answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
92
+ expect(answer_test).to be === answer_correct
95
93
  end
96
94
 
97
95
  it 'retains user-specified prepend commands when adding vrf' do
98
- @options = {
99
- :vrf => 'fakevrf',
96
+ @options = {
97
+ :vrf => 'fakevrf',
100
98
  :user => 'root',
101
99
  }
102
100
  answer_prepend_commands = 'prepend'
103
101
  answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
104
- answer_test = host.prepend_commands( 'fake_command', answer_prepend_commands )
105
- expect( answer_test ).to be === answer_correct
102
+ answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
103
+ expect(answer_test).to be === answer_correct
106
104
  end
107
105
  end
108
106
  end
109
107
 
110
108
  describe '#append_commands' do
111
-
112
109
  context 'for cisco_nexus-7' do
113
-
114
110
  before do
115
111
  @platform = 'cisco_nexus-7-x86_64'
116
112
  @options = { :user => 'non_root' }
@@ -118,38 +114,37 @@ module Cisco
118
114
 
119
115
  it 'appends `"` for commands' do
120
116
  answer_correct = '"'
121
- answer_test = host.append_commands( 'fake_command' )
122
- expect( answer_test ).to be === answer_correct
117
+ answer_test = host.append_commands('fake_command')
118
+ expect(answer_test).to be === answer_correct
123
119
  end
124
120
 
125
121
  it 'returns nil for root user commands' do
126
122
  @options = { :user => 'root' }
127
123
  answer_correct = nil
128
- answer_test = host.append_commands( 'fake_command' )
129
- expect( answer_test ).to be === answer_correct
124
+ answer_test = host.append_commands('fake_command')
125
+ expect(answer_test).to be === answer_correct
130
126
  end
131
127
 
132
128
  it 'returns nil when vsh command' do
133
129
  answer_correct = nil
134
- answer_test = host.append_commands( '/isan/bin/vsh -c foo' )
135
- expect( answer_test ).to be === answer_correct
130
+ answer_test = host.append_commands('/isan/bin/vsh -c foo')
131
+ expect(answer_test).to be === answer_correct
136
132
  end
137
133
 
138
134
  it 'returns `"` when command contains vsh' do
139
135
  answer_correct = '"'
140
- answer_test = host.append_commands( 'fake_command -c foo vsh' )
141
- expect( answer_test ).to be === answer_correct
136
+ answer_test = host.append_commands('fake_command -c foo vsh')
137
+ expect(answer_test).to be === answer_correct
142
138
  end
143
139
 
144
140
  it 'returns nil when ntpdate command' do
145
141
  answer_correct = nil
146
- answer_test = host.append_commands( 'fake/ntpdate/command foo' )
147
- expect( answer_test ).to be === answer_correct
142
+ answer_test = host.append_commands('fake/ntpdate/command foo')
143
+ expect(answer_test).to be === answer_correct
148
144
  end
149
145
  end
150
146
 
151
147
  context 'for cisco_ios_xr-6' do
152
-
153
148
  before do
154
149
  @platform = 'cisco_ios_xr-6-x86_64'
155
150
  @options = { :user => 'non_root' }
@@ -157,41 +152,39 @@ module Cisco
157
152
 
158
153
  it 'appends `"` for commands' do
159
154
  answer_correct = '"'
160
- answer_test = host.append_commands( 'fake_command' )
161
- expect( answer_test ).to be === answer_correct
155
+ answer_test = host.append_commands('fake_command')
156
+ expect(answer_test).to be === answer_correct
162
157
  end
163
158
 
164
159
  it 'returns nil for root user commands' do
165
160
  @options = { :user => 'root' }
166
161
  answer_correct = nil
167
- answer_test = host.append_commands( 'fake_command' )
168
- expect( answer_test ).to be === answer_correct
162
+ answer_test = host.append_commands('fake_command')
163
+ expect(answer_test).to be === answer_correct
169
164
  end
170
165
 
171
166
  it 'returns nil when vsh command' do
172
167
  answer_correct = nil
173
- answer_test = host.append_commands( '/isan/bin/vsh -c foo' )
174
- expect( answer_test ).to be === answer_correct
168
+ answer_test = host.append_commands('/isan/bin/vsh -c foo')
169
+ expect(answer_test).to be === answer_correct
175
170
  end
176
171
 
177
172
  it 'returns `"` when command contains vsh' do
178
173
  answer_correct = '"'
179
- answer_test = host.append_commands( 'fake_command -c foo vsh' )
180
- expect( answer_test ).to be === answer_correct
174
+ answer_test = host.append_commands('fake_command -c foo vsh')
175
+ expect(answer_test).to be === answer_correct
181
176
  end
182
177
 
183
178
  it 'returns nil when ntpdate command' do
184
179
  answer_correct = nil
185
- answer_test = host.append_commands( 'fake/ntpdate/command foo' )
186
- expect( answer_test ).to be === answer_correct
180
+ answer_test = host.append_commands('fake/ntpdate/command foo')
181
+ expect(answer_test).to be === answer_correct
187
182
  end
188
183
  end
189
184
  end
190
185
 
191
186
  describe '#environment_string' do
192
-
193
187
  context 'for cisco_nexus-7' do
194
-
195
188
  before do
196
189
  @platform = 'cisco_nexus-7-x86_64'
197
190
  end
@@ -200,22 +193,22 @@ module Cisco
200
193
  @options = { :user => 'root' }
201
194
  env_map = { 'PATH' => '/opt/pants/2' }
202
195
  answer_correct = ' export PATH="/opt/pants/2";'
203
- answer_test = host.environment_string( env_map )
204
- expect( answer_test ).to be === answer_correct
196
+ answer_test = host.environment_string(env_map)
197
+ expect(answer_test).to be === answer_correct
205
198
  end
206
199
 
207
200
  it 'ends with a semi-colon' do
208
201
  env_map = { 'PATH' => '/opt/pants/3' }
209
- answer_test = host.environment_string( env_map )
210
- expect( answer_test ).to match( /\;$/ )
202
+ answer_test = host.environment_string(env_map)
203
+ expect(answer_test).to match(/\;$/)
211
204
  end
212
205
 
213
206
  it 'turns env maps into paired strings correctly' do
214
207
  @options = { :user => 'root' }
215
208
  env_map = { 'var1' => 'ans1', 'VAR2' => 'ans2' }
216
209
  answer_correct = ' export var1="ans1" VAR1="ans1" VAR2="ans2";'
217
- answer_test = host.environment_string( env_map )
218
- expect( answer_test ).to be === answer_correct
210
+ answer_test = host.environment_string(env_map)
211
+ expect(answer_test).to be === answer_correct
219
212
  end
220
213
  end
221
214
 
@@ -228,80 +221,77 @@ module Cisco
228
221
  @options = { :user => 'notroot' }
229
222
  env_map = { 'PATH' => '/opt/pants/2' }
230
223
  answer_correct = ' env PATH="/opt/pants/2"'
231
- answer_test = host.environment_string( env_map )
232
- expect( answer_test ).to be === answer_correct
224
+ answer_test = host.environment_string(env_map)
225
+ expect(answer_test).to be === answer_correct
233
226
  end
234
227
 
235
228
  it 'uses `env` if root' do
236
229
  @options = { :user => 'root' }
237
230
  env_map = { 'PATH' => '/opt/pants/1' }
238
231
  answer_correct = ' env PATH="/opt/pants/1"'
239
- answer_test = host.environment_string( env_map )
240
- expect( answer_test ).to be === answer_correct
232
+ answer_test = host.environment_string(env_map)
233
+ expect(answer_test).to be === answer_correct
241
234
  end
242
235
 
243
236
  it 'does not end with a semi-colon' do
244
237
  env_map = { 'PATH' => '/opt/pants/3' }
245
- answer_test = host.environment_string( env_map )
246
- expect( answer_test ).not_to match( /\;$/ )
238
+ answer_test = host.environment_string(env_map)
239
+ expect(answer_test).not_to match(/\;$/)
247
240
  end
248
241
 
249
242
  it 'turns env maps into paired strings correctly' do
250
243
  @options = { :user => 'root' }
251
244
  env_map = { 'VAR1' => 'ans1', 'var2' => 'ans2' }
252
245
  answer_correct = ' env VAR1="ans1" var2="ans2" VAR2="ans2"'
253
- answer_test = host.environment_string( env_map )
254
- expect( answer_test ).to be === answer_correct
246
+ answer_test = host.environment_string(env_map)
247
+ expect(answer_test).to be === answer_correct
255
248
  end
256
249
  end
257
250
  end
258
251
 
259
252
  describe '#package_config_dir' do
260
-
261
253
  it 'returns correctly for cisco platforms' do
262
254
  @platform = 'cisco_nexus-7-x86_64'
263
- expect( host.package_config_dir ).to be === '/etc/yum/repos.d/'
255
+ expect(host.package_config_dir).to be === '/etc/yum/repos.d/'
264
256
  end
265
257
  end
266
258
 
267
259
  describe '#repo_type' do
268
-
269
260
  it 'returns correctly for cisco platforms' do
270
261
  @platform = 'cisco_nexus-7-x86_64'
271
- expect( host.repo_type ).to be === 'rpm'
262
+ expect(host.repo_type).to be === 'rpm'
272
263
  end
273
264
  end
274
265
 
275
266
  describe '#validate_setup' do
276
-
277
267
  context 'on the cisco_nexus-7 platform' do
278
268
  before do
279
269
  @platform = 'cisco_nexus-7-x86_64'
280
270
  end
281
271
 
282
272
  it 'errors when no :vrf value is provided' do
283
- expect {
273
+ expect do
284
274
  host.validate_setup
285
- }.to raise_error( ArgumentError, /provided\ with\ a\ \:vrf\ value/ )
275
+ end.to raise_error(ArgumentError, /provided\ with\ a\ \:vrf\ value/)
286
276
  end
287
277
 
288
278
  it 'errors when no :user value is provided' do
289
279
  @options = {
290
- :vrf => 'fake_vrf',
280
+ :vrf => 'fake_vrf',
291
281
  :user => nil,
292
282
  }
293
- expect {
283
+ expect do
294
284
  host.validate_setup
295
- }.to raise_error( ArgumentError, /provided\ with\ a\ \:user\ value/ )
285
+ end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
296
286
  end
297
287
 
298
288
  it 'does nothing if the host is setup correctly' do
299
289
  @options = {
300
- :vrf => 'fake_vrf',
290
+ :vrf => 'fake_vrf',
301
291
  :user => 'notroot',
302
292
  }
303
293
  validate_test = host.validate_setup
304
- expect( validate_test ).to be_nil
294
+ expect(validate_test).to be_nil
305
295
  end
306
296
  end
307
297
 
@@ -312,29 +302,29 @@ module Cisco
312
302
 
313
303
  it 'does nothing if no :vrf value is provided' do
314
304
  @options = {
315
- :user => 'notroot',
305
+ :user => 'notroot',
316
306
  }
317
307
  validate_test = host.validate_setup
318
- expect( validate_test ).to be_nil
308
+ expect(validate_test).to be_nil
319
309
  end
320
310
 
321
311
  it 'errors when no user is provided' do
322
312
  @options = {
323
- :vrf => 'fake_vrf',
313
+ :vrf => 'fake_vrf',
324
314
  :user => nil,
325
315
  }
326
- expect {
316
+ expect do
327
317
  host.validate_setup
328
- }.to raise_error( ArgumentError, /provided\ with\ a\ \:user\ value/ )
318
+ end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
329
319
  end
330
320
 
331
321
  it 'does nothing if the host is setup correctly' do
332
322
  @options = {
333
- :vrf => 'fake_vrf',
323
+ :vrf => 'fake_vrf',
334
324
  :user => 'notroot',
335
325
  }
336
326
  validate_test = host.validate_setup
337
- expect( validate_test ).to be_nil
327
+ expect(validate_test).to be_nil
338
328
  end
339
329
  end
340
330
  end
@@ -3,63 +3,42 @@ require 'spec_helper'
3
3
  module Eos
4
4
  describe Host do
5
5
  let(:options) { @options ? @options : {} }
6
- let(:platform) {
6
+ let(:platform) do
7
7
  if @platform
8
- { :platform => Beaker::Platform.new( @platform) }
8
+ { :platform => Beaker::Platform.new(@platform) }
9
9
  else
10
- { :platform => Beaker::Platform.new( 'eos-vers-arch-extra' ) }
11
- end
12
- }
13
- let(:host) { make_host( 'name', options.merge(platform) ) }
14
-
15
- describe '#puppet_agent_dev_package_info' do
16
- it 'raises an error if puppet_collection isn\'t passed' do
17
- expect { host.puppet_agent_dev_package_info(nil, 'maybe') }.to raise_error(ArgumentError)
18
- end
19
-
20
- it 'raises as error if puppet_agent_version isn\'t passed' do
21
- expect { host.puppet_agent_dev_package_info('maybe', nil) }.to raise_error(ArgumentError)
22
- end
23
-
24
- it 'returns two strings that include the passed parameters' do
25
- return1, return2 = host.puppet_agent_dev_package_info('pc1', 'pav1')
26
- expect( return1 ).to match(/pc1/)
27
- expect( return2 ).to match(/pav1/)
28
- end
29
-
30
- it 'gets the correct file type' do
31
- _, return2 = host.puppet_agent_dev_package_info('pc1', 'pav1')
32
- expect( return2 ).to match(/swix/)
10
+ { :platform => Beaker::Platform.new('eos-vers-arch-extra') }
33
11
  end
34
12
  end
13
+ let(:host) { make_host('name', options.merge(platform)) }
35
14
 
36
15
  describe '#get_remote_file' do
37
16
  it 'calls enable first' do
38
- expect( host ).to receive( :execute ).with(/enable/)
39
- host.get_remote_file( 'remote_url' )
17
+ expect(host).to receive(:execute).with(/enable/)
18
+ host.get_remote_file('remote_url')
40
19
  end
41
20
 
42
21
  it 'begins second line with the copy command' do
43
- expect( host ).to receive( :execute ).with(/\ncopy/)
44
- host.get_remote_file( 'remote_url' )
22
+ expect(host).to receive(:execute).with(/\ncopy/)
23
+ host.get_remote_file('remote_url')
45
24
  end
46
25
 
47
26
  it 'ends second line with particular extension location' do
48
- expect( host ).to receive( :execute ).with(/extension\:\'$/)
49
- host.get_remote_file( 'remote_url' )
27
+ expect(host).to receive(:execute).with(/extension\:\'$/)
28
+ host.get_remote_file('remote_url')
50
29
  end
51
30
  end
52
31
 
53
32
  describe '#install_from_file' do
54
33
  it 'calls enable first' do
55
- expect( host ).to receive( :execute ).with(/enable/)
56
- host.install_from_file( 'local_file' )
34
+ expect(host).to receive(:execute).with(/enable/)
35
+ host.install_from_file('local_file')
57
36
  end
58
37
 
59
38
  it 'begins second line with the extension command' do
60
- expect( host ).to receive( :execute ).with(/\nextension/)
61
- host.install_from_file( 'local_file' )
39
+ expect(host).to receive(:execute).with(/\nextension/)
40
+ host.install_from_file('local_file')
62
41
  end
63
42
  end
64
43
  end
65
- end
44
+ end
@@ -20,18 +20,15 @@ module Beaker
20
20
  end
21
21
 
22
22
  let(:opts) { @opts || {} }
23
- let(:logger) { double( 'logger' ).as_null_object }
23
+ let(:logger) { double('logger').as_null_object }
24
24
  let(:instance) { FreeBSDExecTest.new(opts, logger) }
25
25
 
26
26
  context "echo_to_file" do
27
-
28
27
  it "runs the correct echo command" do
29
- expect( Beaker::Command ).to receive(:new).with('printf "127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n" > /etc/hosts').and_return('')
30
- expect( instance ).to receive(:exec).with('').and_return(generate_result("hello", {:exit_code => 0}))
28
+ expect(Beaker::Command).to receive(:new).with('printf "127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n" > /etc/hosts').and_return('')
29
+ expect(instance).to receive(:exec).with('').and_return(generate_result("hello", { :exit_code => 0 }))
31
30
  instance.echo_to_file('127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n', '/etc/hosts')
32
31
  end
33
-
34
32
  end
35
33
  end
36
34
  end
37
-
@@ -19,13 +19,12 @@ module Beaker
19
19
  end
20
20
 
21
21
  def exec
22
- #noop
22
+ # noop
23
23
  end
24
-
25
24
  end
26
25
 
27
26
  let(:opts) { @opts || {} }
28
- let(:logger) { double( 'logger' ).as_null_object }
27
+ let(:logger) { double('logger').as_null_object }
29
28
  let(:instance) { FreeBSDPkgTest.new(opts, logger) }
30
29
  let(:cond) do
31
30
  'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
@@ -33,45 +32,45 @@ module Beaker
33
32
 
34
33
  context "pkg_info_patten" do
35
34
  it "returns correct patterns" do
36
- expect( instance.pkg_info_pattern('rsync') ).to eq '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'
35
+ expect(instance.pkg_info_pattern('rsync')).to eq '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'
37
36
  end
38
37
  end
39
38
 
40
39
  context "check_pkgng_sh" do
41
- it { expect( instance.check_pkgng_sh ).to eq cond }
40
+ it { expect(instance.check_pkgng_sh).to eq cond }
42
41
  end
43
42
 
44
43
  context "pkgng_active?" do
45
44
  it "returns true if pkgng is available" do
46
- expect( instance ).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
47
- expect( Beaker::Command ).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
48
- expect( instance ).to receive(:exec).with('',{:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
49
- expect( instance.pkgng_active? ).to be true
45
+ expect(instance).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
46
+ expect(Beaker::Command).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
47
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
48
+ expect(instance.pkgng_active?).to be true
50
49
  end
51
50
 
52
51
  it "returns false if pkgng is unavailable" do
53
- expect( instance ).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
54
- expect( Beaker::Command ).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
55
- expect( instance ).to receive(:exec).with('',{:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 127}))
56
- expect( instance.pkgng_active? ).to be false
52
+ expect(instance).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
53
+ expect(Beaker::Command).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
54
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 127 }))
55
+ expect(instance.pkgng_active?).to be false
57
56
  end
58
57
  end
59
58
 
60
59
  context "install_package" do
61
60
  context "without pkgng" do
62
61
  it "runs the correct install command" do
63
- expect( instance ).to receive(:pkgng_active?).once.and_return(false)
64
- expect( Beaker::Command ).to receive(:new).with("pkg_add -r rsync", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
65
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
62
+ expect(instance).to receive(:pkgng_active?).once.and_return(false)
63
+ expect(Beaker::Command).to receive(:new).with("pkg_add -r rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
64
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
66
65
  instance.install_package('rsync')
67
66
  end
68
67
  end
69
68
 
70
69
  context "with pkgng" do
71
70
  it "runs the correct install command" do
72
- expect( instance ).to receive(:pkgng_active?).once.and_return(true)
73
- expect( Beaker::Command ).to receive(:new).with("pkg install -y rsync", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
74
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
71
+ expect(instance).to receive(:pkgng_active?).once.and_return(true)
72
+ expect(Beaker::Command).to receive(:new).with("pkg install -y rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
73
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
75
74
  instance.install_package('rsync')
76
75
  end
77
76
  end
@@ -80,23 +79,21 @@ module Beaker
80
79
  context "check_for_package" do
81
80
  context "without pkgng" do
82
81
  it "runs the correct checking command" do
83
- expect( instance ).to receive(:pkgng_active?).once.and_return(false)
84
- expect( Beaker::Command ).to receive(:new).with("pkg_info -Ix '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
85
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
82
+ expect(instance).to receive(:pkgng_active?).once.and_return(false)
83
+ expect(Beaker::Command).to receive(:new).with("pkg_info -Ix '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
84
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
86
85
  instance.check_for_package('rsync')
87
86
  end
88
87
  end
89
88
 
90
89
  context "with pkgng" do
91
90
  it "runs the correct checking command" do
92
- expect( instance ).to receive(:pkgng_active?).once.and_return(true)
93
- expect( Beaker::Command ).to receive(:new).with("pkg info rsync", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
94
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
91
+ expect(instance).to receive(:pkgng_active?).once.and_return(true)
92
+ expect(Beaker::Command).to receive(:new).with("pkg info rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
93
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
95
94
  instance.check_for_package('rsync')
96
95
  end
97
96
  end
98
97
  end
99
-
100
98
  end
101
99
  end
102
-
@@ -17,11 +17,10 @@ module Beaker
17
17
  def to_s
18
18
  "me"
19
19
  end
20
-
21
20
  end
22
21
 
23
22
  let(:opts) { @opts || {} }
24
- let(:logger) { double( 'logger' ).as_null_object }
23
+ let(:logger) { double('logger').as_null_object }
25
24
  let(:instance) { MacExecTest.new(opts, logger) }
26
25
 
27
26
  describe '#selinux_enabled?' do
@@ -36,7 +35,7 @@ module Beaker
36
35
  it 'calls execute with touch and timestamp' do
37
36
  time = '190101010000'
38
37
  path = '/path/to/file'
39
- expect( instance ).to receive(:execute).with("touch -mt #{time} #{path}").and_return(0)
38
+ expect(instance).to receive(:execute).with("touch -mt #{time} #{path}").and_return(0)
40
39
 
41
40
  instance.modified_at(path, time)
42
41
  end