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,12 +4,12 @@ module Beaker
4
4
  SubcommandUtil = Beaker::Subcommands::SubcommandUtil
5
5
  describe Subcommand do
6
6
  let( :subcommand ) {
7
- Beaker::Subcommand.new
7
+ described_class.new
8
8
  }
9
9
 
10
- context '#initialize' do
10
+ describe '#initialize' do
11
11
  it 'creates a cli object' do
12
- expect(subcommand.cli).to be
12
+ expect(subcommand.cli).to be_instance_of(Beaker::CLI)
13
13
  end
14
14
 
15
15
  describe 'File operation initialization for subcommands' do
@@ -33,7 +33,7 @@ module Beaker
33
33
 
34
34
  context 'ensure that beaker options can be passed through' do
35
35
 
36
- let (:beaker_options_list) { [
36
+ let(:beaker_options_list) { [
37
37
  'options-file',
38
38
  'helper',
39
39
  'load-path',
@@ -78,7 +78,7 @@ module Beaker
78
78
 
79
79
  let( :yaml_store_mock ) { double('yaml_store_mock') }
80
80
 
81
- it 'should not error with valid beaker options' do
81
+ it 'does not error with valid beaker options' do
82
82
  beaker_options_list.each do |option|
83
83
  allow_any_instance_of(Beaker::CLI).to receive(:parse_options)
84
84
  allow_any_instance_of(Beaker::CLI).to receive(:configured_options).and_return({})
@@ -91,27 +91,27 @@ module Beaker
91
91
  expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
92
92
  expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
93
93
 
94
- expect {Beaker::Subcommand.start(['init', '--hosts', 'centos', "--#{option}"])}.to_not output(/ERROR/).to_stderr
94
+ expect {described_class.start(['init', '--hosts', 'centos', "--#{option}"])}.not_to output(/ERROR/).to_stderr
95
95
  end
96
96
  end
97
97
 
98
- it "should error with a bad option here" do
98
+ it "errors with a bad option here" do
99
99
  allow(YAML::Store).to receive(:new).with(SubcommandUtil::SUBCOMMAND_STATE).and_return(yaml_store_mock)
100
100
  allow(yaml_store_mock).to receive(:transaction).and_yield
101
101
  allow(yaml_store_mock).to receive(:[]=).with('provisioned', false)
102
102
  expect(File).not_to receive(:open)
103
103
  expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
104
104
  expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
105
- expect {Beaker::Subcommand.start(['init', '--hosts', 'centos', '--bad-option'])}.to output(/ERROR/).to_stderr
105
+ expect {described_class.start(['init', '--hosts', 'centos', '--bad-option'])}.to output(/ERROR/).to_stderr
106
106
  end
107
107
  end
108
108
 
109
- context '#init' do
109
+ describe '#init' do
110
110
  let( :cli ) { subcommand.cli }
111
111
  let( :mock_options ) { {:timestamp => 'noon', :other_key => 'cordite'}}
112
112
  let( :yaml_store_mock ) { double('yaml_store_mock') }
113
113
 
114
- before :each do
114
+ before do
115
115
  allow(cli).to receive(:parse_options)
116
116
  allow(cli).to receive(:configured_options).and_return(mock_options)
117
117
  end
@@ -130,17 +130,17 @@ module Beaker
130
130
  end
131
131
  end
132
132
 
133
- context '#provision' do
134
- let ( :cli ) { subcommand.cli }
133
+ describe '#provision' do
134
+ let( :cli ) { subcommand.cli }
135
135
  let( :yaml_store_mock ) { double('yaml_store_mock') }
136
- let ( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
137
- let ( :cleaned_hosts ) {double()}
138
- let ( :yielded_host_hash ) {double()}
139
- let ( :yielded_host_name) {double()}
140
- let ( :network_manager) {double('network_manager')}
141
- let ( :hosts) {double('hosts')}
142
- let ( :hypervisors) {double('hypervisors')}
143
- let (:options) {double ('options')}
136
+ let( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
137
+ let( :cleaned_hosts ) {double()}
138
+ let( :yielded_host_hash ) {double()}
139
+ let( :yielded_host_name) {double()}
140
+ let( :network_manager) {double('network_manager')}
141
+ let( :hosts) {double('hosts')}
142
+ let( :hypervisors) {double('hypervisors')}
143
+ let(:options) {double('options')}
144
144
 
145
145
  it 'provisions the host and saves the host info' do
146
146
  expect(YAML::Store).to receive(:new).with(SubcommandUtil::SUBCOMMAND_STATE).and_return(yaml_store_mock)
@@ -174,17 +174,21 @@ module Beaker
174
174
  end
175
175
 
176
176
  context 'exec' do
177
- before :each do
177
+ before do
178
178
  allow(subcommand.cli).to receive(:parse_options)
179
179
  allow(subcommand.cli).to receive(:initialize_network_manager)
180
180
  allow(subcommand.cli).to receive(:execute!)
181
181
  end
182
182
 
183
+ let( :cleaned_hosts ) {double()}
184
+ let( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
185
+ let( :yaml_store_mock ) { double('yaml_store_mock') }
186
+
183
187
  it 'calls execute! when no resource is given' do
184
- expect_any_instance_of(Pathname).to_not receive(:directory?)
185
- expect_any_instance_of(Pathname).to_not receive(:exist?)
188
+ expect_any_instance_of(Pathname).not_to receive(:directory?)
189
+ expect_any_instance_of(Pathname).not_to receive(:exist?)
186
190
  expect(subcommand.cli).to receive(:execute!).once
187
- expect{subcommand.exec}.to_not raise_error
191
+ expect{subcommand.exec}.not_to raise_error
188
192
  end
189
193
 
190
194
  it 'allows hard coded suite names to be specified' do
@@ -251,9 +255,7 @@ module Beaker
251
255
  end
252
256
 
253
257
 
254
- let( :yaml_store_mock ) { double('yaml_store_mock') }
255
- let( :host_hash ) { {'mynode.net' => {:name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64')}}}
256
- let( :cleaned_hosts ) {double()}
258
+
257
259
  it 'updates the subcommand_options file with new host info if `preserve-state` is set' do
258
260
  allow(yaml_store_mock).to receive(:[]).and_return(false)
259
261
  allow(subcommand).to receive(:options).and_return('preserve-state' => true)
@@ -272,7 +274,7 @@ module Beaker
272
274
  it 'does not attempt preserve state if the flag is not passed in' do
273
275
  subcommand.exec('tests')
274
276
 
275
- expect(SubcommandUtil).to receive(:sanitize_options_for_save).never
277
+ expect(SubcommandUtil).not_to receive(:sanitize_options_for_save)
276
278
  expect(subcommand.cli.options['preserve-state']).to be_nil
277
279
  end
278
280
  end
@@ -4,7 +4,7 @@ module Beaker
4
4
  describe TestCase do
5
5
  let(:logger) { double('logger').as_null_object }
6
6
  let(:path) { @path || '/tmp/nope' }
7
- let(:testcase) { TestCase.new({}, logger, {}, path) }
7
+ let(:testcase) { described_class.new({}, logger, {}, path) }
8
8
 
9
9
  context 'run_test' do
10
10
  it 'defaults to test_status :pass on success' do
@@ -13,10 +13,9 @@ module Beaker
13
13
  f.write ""
14
14
  end
15
15
  @path = path
16
- expect( testcase ).to_not receive( :log_and_fail_test )
16
+ expect( testcase ).not_to receive( :log_and_fail_test )
17
17
  testcase.run_test
18
- status = testcase.instance_variable_get(:@test_status)
19
- expect(status).to be === :pass
18
+ expect(testcase.test_status).to be === :pass
20
19
  end
21
20
 
22
21
  it 'updates test_status to :skip on SkipTest' do
@@ -25,10 +24,9 @@ module Beaker
25
24
  f.write "raise SkipTest"
26
25
  end
27
26
  @path = path
28
- expect( testcase ).to_not receive( :log_and_fail_test )
27
+ expect( testcase ).not_to receive( :log_and_fail_test )
29
28
  testcase.run_test
30
- status = testcase.instance_variable_get(:@test_status)
31
- expect(status).to be === :skip
29
+ expect(testcase.test_status).to be === :skip
32
30
  end
33
31
 
34
32
  it 'updates test_status to :pending on PendingTest' do
@@ -37,10 +35,9 @@ module Beaker
37
35
  f.write "raise PendingTest"
38
36
  end
39
37
  @path = path
40
- expect( testcase ).to_not receive( :log_and_fail_test )
38
+ expect( testcase ).not_to receive( :log_and_fail_test )
41
39
  testcase.run_test
42
- status = testcase.instance_variable_get(:@test_status)
43
- expect(status).to be === :pending
40
+ expect(testcase.test_status).to be === :pending
44
41
  end
45
42
 
46
43
  it 'updates test_status to :fail on FailTest' do
@@ -51,8 +48,7 @@ module Beaker
51
48
  @path = path
52
49
  expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Beaker::DSL::FailTest), :fail).and_call_original
53
50
  testcase.run_test
54
- status = testcase.instance_variable_get(:@test_status)
55
- expect(status).to be === :fail
51
+ expect(testcase.test_status).to be === :fail
56
52
  end
57
53
 
58
54
  it 'correctly handles RuntimeError' do
@@ -107,7 +103,7 @@ module Beaker
107
103
  @path = path
108
104
  expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
109
105
  testcase.run_test
110
- expect @test_status == :error
106
+ expect(testcase.test_status).to eq(:error)
111
107
  end
112
108
 
113
109
  it 'does not overwrite a test failure if an assertion also happens in a teardown block' do
@@ -124,7 +120,7 @@ module Beaker
124
120
  expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :fail).and_call_original
125
121
  expect( testcase ).to receive( :log_and_fail_test ).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
126
122
  testcase.run_test
127
- expect @test_status == :fail
123
+ expect(testcase.test_status).to eq(:fail)
128
124
  end
129
125
  end
130
126
 
@@ -148,7 +144,7 @@ module Beaker
148
144
  end
149
145
  @path = path
150
146
  # we have to create a TestCase by hand, so that we can set old
151
- tc = TestCase.new({}, logger, {}, path)
147
+ tc = described_class.new({}, logger, {}, path)
152
148
  # metadata on it, so that we can test that it's being reset correctly
153
149
  old_metadata = { :step => { :name => 'CharlieBrown' } }
154
150
  tc.instance_variable_set(:@metadata, old_metadata)
@@ -13,12 +13,12 @@ module Beaker
13
13
  let(:sh_test) { File.expand_path(test_dir + '/my_shell_file.sh') }
14
14
 
15
15
  it 'fails without test files' do
16
- expect { Beaker::TestSuite.new('name', 'hosts', Hash.new, Time.now, :stop_on_error) }.to raise_error
16
+ expect { described_class.new('name', 'hosts', Hash.new, Time.now, :stop_on_error) }.to raise_error
17
17
  end
18
18
 
19
19
  it 'includes specific files as test file when explicitly passed' do
20
20
  @files = [ rb_test ]
21
- ts = Beaker::TestSuite.new('name', 'hosts', options, Time.now, :stop_on_error)
21
+ ts = described_class.new('name', 'hosts', options, Time.now, :stop_on_error)
22
22
 
23
23
  tfs = ts.instance_variable_get(:@test_files)
24
24
  expect(tfs).to include rb_test
@@ -26,14 +26,14 @@ module Beaker
26
26
 
27
27
  it 'defaults to :slow fail_mode if not provided through parameter or options' do
28
28
  @files = [ rb_test ]
29
- ts = Beaker::TestSuite.new('name', 'hosts', options, Time.now)
29
+ ts = described_class.new('name', 'hosts', options, Time.now)
30
30
  tfm = ts.instance_variable_get(:@fail_mode)
31
31
  expect(tfm).to be == :slow
32
32
  end
33
33
 
34
34
  it 'uses provided parameter fail_mode' do
35
35
  @files = [ rb_test ]
36
- ts = Beaker::TestSuite.new('name', 'hosts', options, Time.now, :fast)
36
+ ts = described_class.new('name', 'hosts', options, Time.now, :fast)
37
37
  tfm = ts.instance_variable_get(:@fail_mode)
38
38
  expect(tfm).to be == :fast
39
39
  end
@@ -41,7 +41,7 @@ module Beaker
41
41
  it 'uses options fail_mode if fail_mode parameter is not provided' do
42
42
  @files = [ rb_test ]
43
43
  options[:fail_mode] = :fast
44
- ts = Beaker::TestSuite.new('name', 'hosts', options, Time.now)
44
+ ts = described_class.new('name', 'hosts', options, Time.now)
45
45
  tfm = ts.instance_variable_get(:@fail_mode)
46
46
  expect(tfm).to be == :fast
47
47
  end
@@ -65,7 +65,7 @@ module Beaker
65
65
  File.open(pl_test, 'w') { |file| file.write(okay_script) }
66
66
  File.open(sh_test, 'w') { |file| file.write(okay_script) }
67
67
 
68
- ts = Beaker::TestSuite.new( 'name', hosts, options, Time.now, :stop )
68
+ ts = described_class.new( 'name', hosts, options, Time.now, :stop )
69
69
  tsr = ts.instance_variable_get( :@test_suite_results )
70
70
  allow( tsr ).to receive(:write_junit_xml).and_return( true )
71
71
  allow( tsr ).to receive(:summarize).and_return( true )
@@ -85,7 +85,7 @@ module Beaker
85
85
  File.open(pl_test, 'w') { |file| file.write(okay_script) }
86
86
  File.open(sh_test, 'w') { |file| file.write(okay_script) }
87
87
 
88
- ts = Beaker::TestSuite.new( 'name', hosts, options, Time.now, :stop )
88
+ ts = described_class.new( 'name', hosts, options, Time.now, :stop )
89
89
  tsr = ts.instance_variable_get( :@test_suite_results )
90
90
  allow( tsr ).to receive(:write_junit_xml).and_return( true )
91
91
  allow( tsr ).to receive(:summarize).and_return( true )
@@ -105,7 +105,7 @@ module Beaker
105
105
  File.open(pl_test, 'w') { |file| file.write(fail_script) }
106
106
  File.open(sh_test, 'w') { |file| file.write(okay_script) }
107
107
 
108
- ts = Beaker::TestSuite.new( 'name', hosts, options, Time.now, :slow )
108
+ ts = described_class.new( 'name', hosts, options, Time.now, :slow )
109
109
  tsr = ts.instance_variable_get( :@test_suite_results )
110
110
  allow( tsr ).to receive(:write_junit_xml).and_return( true )
111
111
  allow( tsr ).to receive(:summarize).and_return( true )
@@ -126,7 +126,7 @@ module Beaker
126
126
  let( :testcase1 ) { Beaker::TestCase.new( hosts, options[:logger], options) }
127
127
  let( :testcase2 ) { Beaker::TestCase.new( hosts, options[:logger], options) }
128
128
  let( :testcase3 ) { Beaker::TestCase.new( hosts, options[:logger], options) }
129
- let( :test_suite_result ) { TestSuiteResult.new( options, "my_suite") }
129
+ let( :test_suite_result ) { described_class.new( options, "my_suite") }
130
130
 
131
131
  it 'supports adding test cases' do
132
132
  expect( test_suite_result.test_count ).to be === 0
@@ -232,7 +232,7 @@ module Beaker
232
232
  tc.instance_variable_set(:@exception, ex)
233
233
  test_suite_result.add_test_case( tc )
234
234
  expect(test_suite_result.print_test_result(tc)).not_to match(/Test line:/)
235
- expect{ test_suite_result.print_test_result(tc) }.to_not raise_error
235
+ expect{ test_suite_result.print_test_result(tc) }.not_to raise_error
236
236
  end
237
237
 
238
238
  it 'prints the test result and line number from test case file on failure' do
@@ -242,7 +242,7 @@ module Beaker
242
242
  tc.instance_variable_set(:@exception, ex)
243
243
  test_suite_result.add_test_case( tc )
244
244
  expect(test_suite_result.print_test_result(tc)).to match(/Test line:/)
245
- expect{ test_suite_result.print_test_result(tc) }.to_not raise_error
245
+ expect{ test_suite_result.print_test_result(tc) }.not_to raise_error
246
246
  end
247
247
  end
248
248
 
@@ -253,14 +253,14 @@ module Beaker
253
253
  :xml_dated_dir => '.'}) }
254
254
  let(:rb_test) { 'my_ruby_file.rb' }
255
255
 
256
- before(:each) do
256
+ before do
257
257
  @files = [ rb_test, rb_test, rb_test]
258
258
  @ts = Beaker::TestSuite.new( 'name', hosts, options, Time.now, :fast )
259
259
  @tsr = @ts.instance_variable_get( :@test_suite_results )
260
260
  allow( @tsr ).to receive( :start_time ).and_return(0)
261
261
  allow( @tsr ).to receive( :stop_time ).and_return(10)
262
262
  @test_cases = []
263
- @files.each_with_index do |file, index|
263
+ @files.each_with_index do |_file, _index|
264
264
  tc = Beaker::TestCase.new( hosts, options[:logger], options, rb_test)
265
265
  allow( tc ).to receive( :sublog ).and_return( false )
266
266
  @test_cases << tc
@@ -271,7 +271,7 @@ module Beaker
271
271
  end
272
272
 
273
273
  it 'doesn\'t re-order test cases themselves on time_sort' do
274
- expect( @tsr.instance_variable_get( :@logger ) ).to receive( :error ).never
274
+ expect( @tsr.instance_variable_get( :@logger ) ).not_to receive( :error )
275
275
 
276
276
  @test_cases.each_with_index do |tc,index|
277
277
  tc.instance_variable_set(:@runtime, 3**index)
@@ -286,7 +286,7 @@ module Beaker
286
286
  end
287
287
 
288
288
  it 'writes @export nested hashes properly' do
289
- expect( @tsr.instance_variable_get( :@logger ) ).to receive( :error ).never
289
+ expect( @tsr.instance_variable_get( :@logger ) ).not_to receive( :error )
290
290
  inner_value = {'second' => '2nd'}
291
291
  @test_cases.each do |tc|
292
292
  tc.instance_variable_set(:@runtime, 0)
@@ -301,7 +301,7 @@ module Beaker
301
301
  end
302
302
 
303
303
  it 'writes @export array of hashes properly' do
304
- expect( @tsr.instance_variable_get( :@logger ) ).to receive( :error ).never
304
+ expect( @tsr.instance_variable_get( :@logger ) ).not_to receive( :error )
305
305
  @test_cases.each do |tc|
306
306
  tc.instance_variable_set(:@runtime, 0)
307
307
  tc.instance_variable_set(:@exports, [{:yes => 'hello'}, {:uh => 'sher'}])
@@ -315,7 +315,7 @@ module Beaker
315
315
  end
316
316
 
317
317
  it 'writes @export hashes per test case properly' do
318
- expect( @tsr.instance_variable_get( :@logger ) ).to receive( :error ).never
318
+ expect( @tsr.instance_variable_get( :@logger ) ).not_to receive( :error )
319
319
  @test_cases.each_with_index do |tc,index|
320
320
  tc.instance_variable_set(:@runtime, 0)
321
321
  tc.instance_variable_set(:@exports, [{"yes_#{index}" => "hello#{index}"}])
@@ -337,7 +337,7 @@ module Beaker
337
337
  let( :files ) { @files ? @files : [sh_test] }
338
338
  let( :options ) { make_opts.merge({ :logger => double().as_null_object, 'name' => create_files(files) }) }
339
339
  let( :hosts ) { make_hosts() }
340
- let( :testsuite ) { Beaker::TestSuite.new( 'name', hosts, options, Time.now, :stop ) }
340
+ let( :testsuite ) { described_class.new( 'name', hosts, options, Time.now, :stop ) }
341
341
 
342
342
  it 'returns the simple joining of the log dir & file as required' do
343
343
  expect(testsuite.log_path('foo.txt', 'man/date')).to be === 'man/date/foo.txt'
@@ -347,15 +347,15 @@ module Beaker
347
347
  # the base directory is where the latest symlink itself should live
348
348
 
349
349
  it 'in the usual case' do
350
- expect( File.symlink?('man/latest') ).to be_falsy
350
+ expect( File ).not_to be_symlink('man/latest')
351
351
  testsuite.log_path('foo.txt', 'man/date')
352
- expect( File.symlink?('man/latest') ).to be_truthy
352
+ expect( File ).to be_symlink('man/latest')
353
353
  end
354
354
 
355
355
  it 'if given a nested directory' do
356
- expect( File.symlink?('a/latest') ).to be_falsy
356
+ expect( File ).not_to be_symlink('a/latest')
357
357
  testsuite.log_path('foo.txt', 'a/b/c/d/e/f')
358
- expect( File.symlink?('a/latest') ).to be_truthy
358
+ expect( File ).to be_symlink('a/latest')
359
359
  end
360
360
  end
361
361
 
@@ -363,13 +363,13 @@ module Beaker
363
363
  # the symlink directory is where the symlink points to
364
364
 
365
365
  it 'in the usual case' do
366
- expect( File.symlink?('d/latest') ).to be_falsy
366
+ expect( File ).not_to be_symlink('d/latest')
367
367
  testsuite.log_path('foo.txt', 'd/e')
368
368
  expect( File.readlink('d/latest') ).to be === 'e'
369
369
  end
370
370
 
371
371
  it 'if given a nested directory' do
372
- expect( File.symlink?('f/latest') ).to be_falsy
372
+ expect( File ).not_to be_symlink('f/latest')
373
373
  testsuite.log_path('foo.txt', 'f/g/h/i/j/k')
374
374
  expect( File.readlink('f/latest') ).to be === 'g/h/i/j/k'
375
375
  end
data/spec/matchers.rb CHANGED
@@ -53,7 +53,7 @@ RSpec::Matchers.define :execute_commands_matching_in_order do |*patterns|
53
53
  end
54
54
 
55
55
  def message(actual, patterns)
56
- msg = "#{patterns.join(', ')} in order" +
56
+ "#{patterns.join(', ')} in order" +
57
57
  " in:\n #{actual.command_strings.pretty_inspect}"
58
58
  end
59
59
 
data/spec/mocks.rb CHANGED
@@ -26,7 +26,7 @@ module MockNet
26
26
  @uri = uri
27
27
  end
28
28
 
29
- def body= *args
29
+ def body= *_args
30
30
  hash
31
31
  end
32
32
  end
@@ -36,7 +36,7 @@ module MockNet
36
36
  @uri = uri
37
37
  end
38
38
 
39
- def body= *args
39
+ def body= *_args
40
40
  hash
41
41
  end
42
42
  end
@@ -52,7 +52,7 @@ module MockNet
52
52
  @port = port
53
53
  end
54
54
 
55
- def request req
55
+ def request _req
56
56
  Response.new
57
57
  end
58
58
  end
@@ -80,7 +80,7 @@ module FakeHost
80
80
 
81
81
  attr_accessor :commands
82
82
 
83
- def port_open?(port)
83
+ def port_open?(_port)
84
84
  true
85
85
  end
86
86
 
@@ -88,7 +88,7 @@ module FakeHost
88
88
  RSpec::Mocks::Double.new('exec-result').as_null_object
89
89
  end
90
90
 
91
- def exec(command, options = {})
91
+ def exec(command, _options = {})
92
92
  commands << command
93
93
  any_exec_result
94
94
  end
data/spec/spec_helper.rb CHANGED
@@ -27,9 +27,6 @@ require 'fakefs/spec_helpers'
27
27
  require 'mocks'
28
28
  require 'helpers'
29
29
  require 'matchers'
30
- require 'mock_fission'
31
- require 'mock_vsphere'
32
- require 'mock_vsphere_helper'
33
30
  require 'rspec/its'
34
31
 
35
32
  RSpec.configure do |config|