beaker 4.38.1 → 4.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +72 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +9 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -59
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
@@ -4,13 +4,13 @@ module Beaker
4
4
  module Options
5
5
 
6
6
  describe Validator do
7
- let(:validator) { Validator.new }
7
+ let(:validator) { described_class.new }
8
8
 
9
9
  describe '#check_yaml_file' do
10
10
  let(:bad_yaml_path) { File.join(File.expand_path(File.dirname(__FILE__)), 'data', 'badyaml.cfg') }
11
11
  let(:yaml_path) { File.join(File.expand_path(File.dirname(__FILE__)), 'data', 'hosts.cfg') }
12
12
 
13
- before :each do
13
+ before do
14
14
  FakeFS.deactivate!
15
15
  end
16
16
 
@@ -23,7 +23,7 @@ module Beaker
23
23
  end
24
24
 
25
25
  it 'does not throw errors on valid yaml files' do
26
- expect { validator.check_yaml_file(yaml_path) }.to_not raise_error
26
+ expect { validator.check_yaml_file(yaml_path) }.not_to raise_error
27
27
  end
28
28
  end
29
29
 
@@ -35,7 +35,7 @@ module Beaker
35
35
 
36
36
  describe '#default_set?' do
37
37
  it 'is false when empty' do
38
- expect(validator.default_set?([])).to be_falsey
38
+ expect(validator).not_to be_default_set([])
39
39
  end
40
40
 
41
41
  it 'throws error when more than 1' do
@@ -44,7 +44,7 @@ module Beaker
44
44
 
45
45
  ['test', 1, 3.4, true, Object.new].each do |val|
46
46
  it "is true when contents are #{val.class}" do
47
- expect(validator.default_set?([val])).to be_truthy
47
+ expect(validator).to be_default_set([val])
48
48
  end
49
49
  end
50
50
  end
@@ -52,7 +52,7 @@ module Beaker
52
52
  describe '#valid_fail_mode?' do
53
53
  %w(stop fast slow).each do |val|
54
54
  it "does not throw error when set to #{val}" do
55
- expect { validator.validate_fail_mode(val) }.to_not raise_error
55
+ expect { validator.validate_fail_mode(val) }.not_to raise_error
56
56
  end
57
57
 
58
58
  it "raises error when set to #{val.upcase}" do
@@ -74,7 +74,7 @@ module Beaker
74
74
  describe '#valid_preserve_hosts?' do
75
75
  %w(always onfail onpass never).each do |val|
76
76
  it "does not raise error when set to #{val}" do
77
- expect { validator.validate_preserve_hosts(val) }.to_not raise_error
77
+ expect { validator.validate_preserve_hosts(val) }.not_to raise_error
78
78
  end
79
79
 
80
80
  it "raises error when set to #{val.upcase}" do
@@ -109,7 +109,7 @@ module Beaker
109
109
 
110
110
  expect {
111
111
  validator.validate_test_tags(tag_includes, [], tag_excludes)
112
- }.to_not raise_error
112
+ }.not_to raise_error
113
113
  end
114
114
 
115
115
  it 'raises an error if AND and OR are both used' do
@@ -126,11 +126,11 @@ module Beaker
126
126
 
127
127
  describe '#validate_frictionless_roles' do
128
128
  it 'does nothing when roles are correct' do
129
- expect { validator.validate_frictionless_roles(%w(frictionless)) }.to_not raise_error
130
- expect { validator.validate_frictionless_roles(%w(frictionless agent)) }.to_not raise_error
131
- expect { validator.validate_frictionless_roles(%w(frictionless test1)) }.to_not raise_error
132
- expect { validator.validate_frictionless_roles(%w(frictionless a role)) }.to_not raise_error
133
- expect { validator.validate_frictionless_roles(%w(frictionless frictionless some_role)) }.to_not raise_error
129
+ expect { validator.validate_frictionless_roles(%w(frictionless)) }.not_to raise_error
130
+ expect { validator.validate_frictionless_roles(%w(frictionless agent)) }.not_to raise_error
131
+ expect { validator.validate_frictionless_roles(%w(frictionless test1)) }.not_to raise_error
132
+ expect { validator.validate_frictionless_roles(%w(frictionless a role)) }.not_to raise_error
133
+ expect { validator.validate_frictionless_roles(%w(frictionless frictionless some_role)) }.not_to raise_error
134
134
  end
135
135
 
136
136
  it 'throws errors when roles conflict' do
@@ -144,7 +144,7 @@ module Beaker
144
144
 
145
145
  describe '#validate_master_count' do
146
146
  it 'does nothing when count is exactly 1' do
147
- expect { validator.validate_master_count(1) }.to_not raise_error
147
+ expect { validator.validate_master_count(1) }.not_to raise_error
148
148
  end
149
149
 
150
150
  it 'throws errors when greater than 1' do
@@ -156,8 +156,8 @@ module Beaker
156
156
 
157
157
  describe '#validate_files' do
158
158
  it 'does not throw an error with non-empty list' do
159
- expect { validator.validate_files(['filea'], '.') }.to_not raise_error
160
- expect { validator.validate_files(%w(filea fileb), '.') }.to_not raise_error
159
+ expect { validator.validate_files(['filea'], '.') }.not_to raise_error
160
+ expect { validator.validate_files(%w(filea fileb), '.') }.not_to raise_error
161
161
  end
162
162
 
163
163
  it 'raises error when file list is empty' do
@@ -168,7 +168,7 @@ module Beaker
168
168
  describe '#validate_path' do
169
169
  it 'does not throw an error when path is valid' do
170
170
  FakeFS do
171
- expect { validator.validate_path('.') }.to_not raise_error
171
+ expect { validator.validate_path('.') }.not_to raise_error
172
172
  end
173
173
  end
174
174
 
@@ -182,7 +182,7 @@ module Beaker
182
182
  let(:blank_platform) { {'platform' => ''} }
183
183
 
184
184
  it 'does not throw an error when host has a platform' do
185
- expect { validator.validate_platform(valid_platform, 'vm1') }.to_not raise_error
185
+ expect { validator.validate_platform(valid_platform, 'vm1') }.not_to raise_error
186
186
  end
187
187
 
188
188
  it 'throws an error when platform is not included' do
@@ -4,19 +4,9 @@ module Beaker
4
4
  describe Perf do
5
5
 
6
6
  context "When a Perf object is created" do
7
- it 'creates a new Perf object' do
8
- hosts = Array.new
9
- options = Hash.new
10
- options[:log_level] = :debug
11
- my_logger = Beaker::Logger.new(options)
12
- options[:logger] = my_logger
13
- perf = Perf.new( hosts, options )
14
- expect( perf ).to be_a_kind_of Perf
15
- end
16
-
17
- before(:each) do
7
+ before do
18
8
  @options = make_opts
19
- @options[:collect_perf_data] = true
9
+ @options[:collect_perf_data] = 'normal'
20
10
  @options[:log_level] = :debug
21
11
  @options[:color] = false
22
12
  @my_io = StringIO.new
@@ -25,40 +15,51 @@ module Beaker
25
15
  @options[:logger] = @my_logger
26
16
  end
27
17
 
28
- it 'creates a new Perf object with a single host, :collect_perf_data = true' do
18
+ it 'creates a new Perf object' do
19
+ hosts = Array.new
20
+ options = Hash.new
21
+ options[:log_level] = :debug
22
+ my_logger = Beaker::Logger.new(options)
23
+ options[:logger] = my_logger
24
+ perf = described_class.new( hosts, options )
25
+ expect( perf ).to be_a_kind_of described_class
26
+ end
27
+
28
+
29
+ it 'creates a new Perf object with a single host' do
29
30
  hosts = [ make_host("myHost", @options) ]
30
31
  hosts.each { |host| host['platform'] = "centos-6-x86_64" }
31
32
  @my_logger.remove_destination(STDOUT)
32
- perf = Perf.new( hosts, @options )
33
- expect( perf ).to be_a_kind_of Perf
33
+ perf = described_class.new( hosts, @options )
34
+ expect( perf ).to be_a_kind_of described_class
34
35
  expect(@my_io.string).to match(/Setup perf on host: myHost/)
35
36
  end
36
37
 
37
- it 'creates a new Perf object with multiple hosts, :collect_perf_data = true' do
38
+ it 'creates a new Perf object with multiple hosts' do
38
39
  hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
39
40
  hosts.each { |host| host['platform'] = "centos-6-x86_64" }
40
41
  @my_logger.remove_destination(STDOUT)
41
- perf = Perf.new( hosts, @options )
42
- expect( perf ).to be_a_kind_of Perf
42
+ perf = described_class.new( hosts, @options )
43
+ expect( perf ).to be_a_kind_of described_class
43
44
  expect(@my_io.string).to match(/Setup perf on host: myHost*\nSetup perf on host: myOtherHost/)
44
45
  end
45
46
 
46
- it 'creates a new Perf object with multiple hosts, :collect_perf_data = true, SLES' do
47
+ it 'creates a new Perf object with multiple hosts, SLES' do
47
48
  hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options) ]
48
49
  hosts[0]['platform'] = "centos-6-x86_64"
49
50
  hosts[1]['platform'] = "sles-11-x86_64"
50
51
  hosts[2]['platform'] = "opensuse-15-x86_64"
51
52
  @my_logger.remove_destination(STDOUT)
52
- perf = Perf.new( hosts, @options )
53
- expect( perf ).to be_a_kind_of Perf
53
+ perf = described_class.new( hosts, @options )
54
+ expect( perf ).to be_a_kind_of described_class
54
55
  expect(@my_io.string).to match(/Setup perf on host: myHost\nSetup perf on host: myOtherHost/)
55
56
  end
56
57
  end
57
58
 
58
- context "When testing is finished, :collect_perf_data = true" do
59
- before(:each) do
59
+ context "When testing is finished" do
60
+ before do
60
61
  @options = make_opts
61
- @options[:collect_perf_data] = true
62
+ @options[:collect_perf_data] = 'normal'
62
63
  @options[:log_level] = :debug
63
64
  @options[:color] = false
64
65
  @hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
@@ -71,8 +72,8 @@ module Beaker
71
72
  it "Does the Right Thing on Linux hosts" do
72
73
  @hosts[0]['platform'] = "centos-6-x86_64"
73
74
  @my_logger.remove_destination(STDOUT)
74
- perf = Perf.new( @hosts, @options )
75
- expect( perf ).to be_a_kind_of Perf
75
+ perf = described_class.new( @hosts, @options )
76
+ expect( perf ).to be_a_kind_of described_class
76
77
  perf.print_perf_info
77
78
  expect(@my_io.string).to match(/Setup perf on host: myHost\nSetup perf on host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost\nGetting perf data for host: myHost\nGetting perf data for host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost/)
78
79
  end
@@ -80,8 +81,8 @@ module Beaker
80
81
  it "Does the Right Thing on non-Linux hosts" do
81
82
  @hosts[0]['platform'] = "windows"
82
83
  @my_logger.remove_destination(STDOUT)
83
- perf = Perf.new( @hosts, @options )
84
- expect( perf ).to be_a_kind_of Perf
84
+ perf = described_class.new( @hosts, @options )
85
+ expect( perf ).to be_a_kind_of described_class
85
86
  perf.print_perf_info
86
87
  expect(@my_io.string).to match(/Setup perf on host: myHost\nPerf \(sysstat\) not supported on host: myHost\nSetup perf on host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost\nGetting perf data for host: myHost\nPerf \(sysstat\) not supported on host: myHost\nGetting perf data for host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost/)
87
88
  end
@@ -4,7 +4,7 @@ module Beaker
4
4
  describe Platform do
5
5
 
6
6
  let( :logger ) { double( 'logger' ) }
7
- let( :platform ) { Platform.new(@name) }
7
+ let( :platform ) { described_class.new(@name) }
8
8
 
9
9
  context 'initialize' do
10
10
 
@@ -97,6 +97,7 @@ module Beaker
97
97
  expect( platform.with_version_codename ).to be === 'ubuntu-xenial-xxx'
98
98
 
99
99
  end
100
+
100
101
  it "can convert ubuntu-1310-xxx to ubuntu-saucy-xxx" do
101
102
  @name = 'ubuntu-1310-xxx'
102
103
  expect( platform.with_version_codename ).to be === 'ubuntu-saucy-xxx'
@@ -160,7 +161,7 @@ module Beaker
160
161
  if YAML.respond_to?(:unsafe_load)
161
162
  YAML.unsafe_load(YAML.dump(platform))
162
163
  else
163
- YAML.load(YAML.dump(platform))
164
+ YAML.load(YAML.dump(platform)) # rubocop:disable Security/YAMLLoad
164
165
  end
165
166
  end
166
167
 
@@ -7,7 +7,7 @@ module Beaker
7
7
  let( :backtrace ) { "I'm the backtrace\nYes I am!\nI have important information" }
8
8
  let( :logger ) { double( 'logger' ) }
9
9
 
10
- before :each do
10
+ before do
11
11
  allow( logger ).to receive( :error ).and_return( true )
12
12
  allow( logger ).to receive( :pretty_backtrace ).and_return( backtrace )
13
13
 
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  module Beaker
4
4
  module Shared
5
5
  describe FogCredentials do
6
- context "#get_fog_credentials" do
6
+ describe "#get_fog_credentials" do
7
7
  it 'raises ArgumentError when fog file is missing' do
8
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
8
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
9
9
  end
10
10
 
11
11
  it 'raises ArgumentError when fog file is empty' do
12
- expect( File ).to receive( :open ) { "" }
12
+ expect( File ).to receive( :open ).and_return("")
13
13
 
14
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog') }.to raise_error( ArgumentError )
14
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog') }.to raise_error( ArgumentError )
15
15
  end
16
16
 
17
17
  it 'raises ArgumentError when fog file does not contain "default" section and no section is specified' do
@@ -19,7 +19,7 @@ module Beaker
19
19
 
20
20
  expect( YAML ).to receive( :load_file ) { data }
21
21
 
22
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
22
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
23
23
  end
24
24
 
25
25
  it 'raises ArgumentError when fog file does not contain another section passed by argument' do
@@ -27,7 +27,7 @@ module Beaker
27
27
 
28
28
  expect( YAML ).to receive( :load_file ) { data }
29
29
 
30
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :other_credential ) }.to raise_error( ArgumentError )
30
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog', :other_credential ) }.to raise_error( ArgumentError )
31
31
  end
32
32
 
33
33
  it 'raises ArgumentError when there are formatting errors in the fog file' do
@@ -35,7 +35,7 @@ module Beaker
35
35
 
36
36
  expect( YAML ).to receive( :load_file ) { data }
37
37
 
38
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
38
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
39
39
  end
40
40
 
41
41
  it 'raises ArgumentError when there are syntax errors in the fog file' do
@@ -43,7 +43,7 @@ module Beaker
43
43
 
44
44
  allow( File ).to receive( :open ).and_yield( StringIO.new( data ) )
45
45
 
46
- expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError, /Psych::SyntaxError/ )
46
+ expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError, /Psych::SyntaxError/ )
47
47
  end
48
48
 
49
49
  it 'returns the named credential section' do
@@ -54,7 +54,7 @@ module Beaker
54
54
 
55
55
  expect( YAML ).to receive( :load_file ) { data }
56
56
 
57
- expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :other_credential )[:vmpooler_token] ).to eq( "correct_token" )
57
+ expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :other_credential )[:vmpooler_token] ).to eq( "correct_token" )
58
58
  end
59
59
 
60
60
  it 'returns the named credential section from ENV["FOG_CREDENTIAL"]' do
@@ -66,7 +66,7 @@ module Beaker
66
66
 
67
67
  expect( YAML ).to receive( :load_file ) { data }
68
68
 
69
- expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' )[:vmpooler_token] ).to eq( "correct_token" )
69
+ expect( get_fog_credentials( '/path/that/does/not/exist/.fog' )[:vmpooler_token] ).to eq( "correct_token" )
70
70
  ENV.delete( 'FOG_CREDENTIAL' )
71
71
  end
72
72
 
@@ -79,7 +79,7 @@ module Beaker
79
79
 
80
80
  expect( YAML ).to receive( :load_file ) { data }
81
81
 
82
- expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :default )[:vmpooler_token] ).to eq( "correct_token" )
82
+ expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :default )[:vmpooler_token] ).to eq( "correct_token" )
83
83
  ENV.delete( 'FOG_CREDENTIAL' )
84
84
  end
85
85
 
@@ -92,7 +92,7 @@ module Beaker
92
92
 
93
93
  expect( YAML ).to receive( :load_file ).with( '/some/other/path/to/.fog' ) { data }
94
94
 
95
- expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :default )[:vmpooler_token] ).to eq( "correct_token" )
95
+ expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :default )[:vmpooler_token] ).to eq( "correct_token" )
96
96
  end
97
97
  end
98
98
  end
@@ -10,7 +10,7 @@ module Beaker
10
10
  describe HostManager do
11
11
  # The logger double as nil object doesn't work with marshal.load and marshal.unload needed for run_in_parallel.
12
12
  let( :logger ) { double('logger') }
13
- let( :host_handler ) { Beaker::Shared::HostManager }
13
+ let( :host_handler ) { described_class }
14
14
  let( :spec_block ) { Proc.new { |arr| arr } }
15
15
  let( :platform ) { @platform || 'unix' }
16
16
  let( :role0 ) { "role0" }
@@ -22,7 +22,7 @@ module Beaker
22
22
  hosts[2][:roles] = ['agent', role2]
23
23
  hosts }
24
24
 
25
- context "#hosts_with_name" do
25
+ describe "#hosts_with_name" do
26
26
 
27
27
  it "can identify the host by name" do
28
28
 
@@ -59,7 +59,7 @@ module Beaker
59
59
 
60
60
  end
61
61
 
62
- context "#hosts_with_role" do
62
+ describe "#hosts_with_role" do
63
63
  it "can find the master in a set of hosts" do
64
64
 
65
65
  expect( host_handler.hosts_with_role( hosts, 'master' ) ).to be === [hosts[1]]
@@ -80,7 +80,7 @@ module Beaker
80
80
 
81
81
  end
82
82
 
83
- context "#only_host_with_role" do
83
+ describe "#only_host_with_role" do
84
84
  it "can find the single master in a set of hosts" do
85
85
 
86
86
  expect( host_handler.only_host_with_role( hosts, 'master' ) ).to be === hosts[1]
@@ -104,7 +104,7 @@ module Beaker
104
104
  end
105
105
  end
106
106
 
107
- context "#find_at_most_one_host_with_role" do
107
+ describe "#find_at_most_one_host_with_role" do
108
108
  it "can find the single master in a set of hosts" do
109
109
 
110
110
  expect( host_handler.find_at_most_one_host_with_role( hosts, 'master' ) ).to be === hosts[1]
@@ -128,7 +128,7 @@ module Beaker
128
128
  end
129
129
  end
130
130
 
131
- context "#run_block_on" do
131
+ describe "#run_block_on" do
132
132
  it "can execute a block against hosts identified by a string" do
133
133
  myhosts = host_handler.run_block_on( hosts, role0 ) do |hosts|
134
134
  hosts
@@ -165,7 +165,7 @@ module Beaker
165
165
 
166
166
  # After marshal load and marshal unload, the logger option (an rspec double) is no longer 'equal' to the original.
167
167
  # Array of results can be in different order.
168
- new_host = myhosts.select{ |host| host.name == hosts[0].name}.first
168
+ new_host = myhosts.find{ |host| host.name == hosts[0].name}
169
169
  hosts[0].options.each { |option|
170
170
  expect(option[1]).to eq(new_host.options[option[0]]) unless option[0] == :logger
171
171
  }
@@ -16,7 +16,7 @@ module Beaker
16
16
  end
17
17
  end
18
18
 
19
- it "should short circuit if the block is complete" do
19
+ it "shorts circuit if the block is complete" do
20
20
  allow( Time ).to receive( :now ).and_return( 0, 1, 2, 3, 4, 5 )
21
21
 
22
22
  block = double( 'block' )
@@ -37,25 +37,25 @@ module Beaker
37
37
  expect( block ).to receive( :exec ).exactly( 5 ).times.and_return( false )
38
38
  allow( subject ).to receive( 'sleep' ).and_return( true )
39
39
 
40
- expect( subject ).to receive( :sleep ).with( 1 ).exactly( 2 ).times
40
+ expect( subject ).to receive( :sleep ).with( 1 ).twice
41
41
  expect( subject ).to receive( :sleep ).with( 2 ).once
42
42
  expect( subject ).to receive( :sleep ).with( 3 ).once
43
43
  expect( subject ).to receive( :sleep ).with( 5 ).once
44
- expect( subject ).to receive( :sleep ).with( 8 ).never
44
+ expect( subject ).not_to receive( :sleep ).with( 8 )
45
45
 
46
46
  subject.repeat_fibonacci_style_for( 5 ) do
47
47
  block.exec
48
48
  end
49
49
  end
50
50
 
51
- it "should short circuit if the block succeeds (returns true)" do
51
+ it "shorts circuit if the block succeeds (returns true)" do
52
52
  expect(block).to receive(:exec).and_return(false).ordered.exactly(4).times
53
53
  expect(block).to receive(:exec).and_return( true).ordered.once
54
54
 
55
- expect(subject).to receive(:sleep).with(1).exactly(2).times
55
+ expect(subject).to receive(:sleep).with(1).twice
56
56
  expect(subject).to receive(:sleep).with(2).once
57
57
  expect(subject).to receive(:sleep).with(3).once
58
- expect(subject).to receive(:sleep).with(anything).never
58
+ expect(subject).not_to receive(:sleep).with(anything)
59
59
 
60
60
  subject.repeat_fibonacci_style_for(20) do
61
61
  block.exec
@@ -65,9 +65,9 @@ module Beaker
65
65
  it "returns false if block never returns that it is done (true)" do
66
66
  expect(block).to receive(:abcd).exactly(3).times.and_return(false)
67
67
 
68
- expect(subject).to receive(:sleep).with(1).exactly(2).times
68
+ expect(subject).to receive(:sleep).with(1).twice
69
69
  expect(subject).to receive(:sleep).with(2).once
70
- expect(subject).to receive(:sleep).with(anything).never
70
+ expect(subject).not_to receive(:sleep).with(anything)
71
71
 
72
72
  success_result = subject.repeat_fibonacci_style_for(3) do
73
73
  block.abcd
@@ -78,7 +78,7 @@ module Beaker
78
78
  it "never sleeps if block is successful right at first (returns true)" do
79
79
  expect(block).to receive(:fake01).once.and_return(true)
80
80
 
81
- expect(subject).to receive(:sleep).never
81
+ expect(subject).not_to receive(:sleep)
82
82
 
83
83
  subject.repeat_fibonacci_style_for(3) do
84
84
  block.fake01
@@ -3,6 +3,8 @@ require 'net/ssh'
3
3
 
4
4
  module Beaker
5
5
  describe SshConnection do
6
+ subject(:connection) { described_class.new name_hash, user, ssh_opts, options }
7
+
6
8
  let( :user ) { 'root' }
7
9
  let( :ssh_opts ) { { keepalive: true, keepalive_interval: 2 } }
8
10
  let( :options ) { { :logger => double('logger').as_null_object, :ssh_connection_preference => [:ip, :vmhostname, :hostname]} }
@@ -10,16 +12,16 @@ module Beaker
10
12
  let( :vmhostname ){ "vmhostname" }
11
13
  let( :hostname) { "my_host" }
12
14
  let( :name_hash ) { { :ip => ip, :vmhostname => vmhostname, :hostname => hostname } }
13
- subject(:connection) { SshConnection.new name_hash, user, ssh_opts, options }
14
15
 
15
- before :each do
16
+
17
+ before do
16
18
  allow( subject ).to receive(:sleep)
17
19
  end
18
20
 
19
21
  it 'self.connect creates connects and returns a proxy for that connection' do
20
22
  expect( Net::SSH ).to receive(:start).with( "default.ip.address", user, ssh_opts ).and_return(true)
21
- connection_constructor = SshConnection.connect name_hash, user, ssh_opts, options
22
- expect( connection_constructor ).to be_a_kind_of SshConnection
23
+ connection_constructor = described_class.connect name_hash, user, ssh_opts, options
24
+ expect( connection_constructor ).to be_a_kind_of described_class
23
25
  end
24
26
 
25
27
  it 'connect creates a new connection' do
@@ -35,7 +37,7 @@ module Beaker
35
37
  it 'attempts to connect by vmhostname address if ip connection fails' do
36
38
  expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(false)
37
39
  expect( Net::SSH ).to receive( :start ).with( vmhostname, user, ssh_opts).and_return(true).once
38
- expect( Net::SSH ).to receive( :start ).with( hostname, user, ssh_opts).never
40
+ expect( Net::SSH ).not_to receive( :start ).with( hostname, user, ssh_opts)
39
41
  connection.connect
40
42
  end
41
43
 
@@ -111,7 +113,7 @@ module Beaker
111
113
  end
112
114
 
113
115
  describe '#register_stdout_for' do
114
- before :each do
116
+ before do
115
117
  @mock_ssh = Object.new
116
118
  expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
117
119
  connection.connect
@@ -147,7 +149,7 @@ module Beaker
147
149
  describe '#register_stderr_for' do
148
150
  let( :result ) { Beaker::Result.new('hostname', 'command') }
149
151
 
150
- before :each do
152
+ before do
151
153
  @mock_ssh = Object.new
152
154
  expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
153
155
  connection.connect
@@ -175,9 +177,9 @@ module Beaker
175
177
  allow( @mock_channel ).to receive( :on_extended_data ).and_yield(nil, '1', @data)
176
178
 
177
179
  @mock_callback = Object.new
178
- expect( @mock_callback ).to_not receive( :[] )
179
- expect( result.stderr ).to_not receive( :<< )
180
- expect( result.output ).to_not receive( :<< )
180
+ expect( @mock_callback ).not_to receive( :[] )
181
+ expect( result.stderr ).not_to receive( :<< )
182
+ expect( result.output ).not_to receive( :<< )
181
183
 
182
184
  connection.register_stderr_for @mock_channel, result, @mock_callback
183
185
  end
@@ -216,7 +218,7 @@ module Beaker
216
218
  end
217
219
 
218
220
  describe '#scp_to' do
219
- before :each do
221
+ before do
220
222
  @mock_ssh = Object.new
221
223
  @mock_scp = Object.new
222
224
  allow( @mock_scp ).to receive( :upload! )
@@ -243,7 +245,7 @@ module Beaker
243
245
  end
244
246
 
245
247
  describe '#scp_from' do
246
- before :each do
248
+ before do
247
249
  @mock_ssh = Object.new
248
250
  @mock_scp = Object.new
249
251
  allow( @mock_scp ).to receive( :download! )
@@ -60,15 +60,19 @@ module Beaker
60
60
  it "determines if we should execute the init subcommand" do
61
61
  expect(subject.execute_subcommand?("init")).to be == true
62
62
  end
63
+
63
64
  it "does not attempt to execute intialize as a subcommand" do
64
65
  expect(subject.execute_subcommand?("initialize")).to be == false
65
66
  end
67
+
66
68
  it "determines if we should execute the help subcommand" do
67
69
  expect(subject.execute_subcommand?("help")).to be == true
68
70
  end
71
+
69
72
  it "determines if we should execute the provision subcommand" do
70
73
  expect(subject.execute_subcommand?("provision")).to be == true
71
74
  end
75
+
72
76
  it "determines that a subcommand should not be executed" do
73
77
  expect(subject.execute_subcommand?("notasubcommand")).to be == false
74
78
  end
@@ -77,15 +81,16 @@ module Beaker
77
81
 
78
82
  describe 'error_with' do
79
83
  it "the exit value should default to 1" do
80
- expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
84
+ expect(STDOUT).to receive(:puts).with("exiting").once
81
85
  begin
82
86
  subject.error_with("exiting")
83
87
  rescue SystemExit=>e
84
88
  expect(e.status).to eq(1)
85
89
  end
86
90
  end
91
+
87
92
  it "the exit value should return specified value" do
88
- expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
93
+ expect(STDOUT).to receive(:puts).with("exiting").once
89
94
  begin
90
95
  subject.error_with("exiting", {exit_code: 3})
91
96
  rescue SystemExit=>e
@@ -94,8 +99,8 @@ module Beaker
94
99
  end
95
100
 
96
101
  it "the exit value should default to 1 with a stack trace" do
97
- expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
98
- expect(STDOUT).to receive(:puts).with("testing").exactly(1).times
102
+ expect(STDOUT).to receive(:puts).with("exiting").once
103
+ expect(STDOUT).to receive(:puts).with("testing").once
99
104
  begin
100
105
  subject.error_with("exiting", {stack_trace: "testing"})
101
106
  rescue SystemExit=>e