beaker 1.21.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/CONTRIBUTING.md +1 -0
  5. data/HISTORY.md +17288 -2
  6. data/Rakefile +6 -2
  7. data/beaker.gemspec +15 -19
  8. data/lib/beaker.rb +2 -5
  9. data/lib/beaker/answers.rb +2 -0
  10. data/lib/beaker/answers/version34.rb +37 -1
  11. data/lib/beaker/cli.rb +4 -0
  12. data/lib/beaker/command.rb +16 -84
  13. data/lib/beaker/command_factory.rb +13 -2
  14. data/lib/beaker/dsl/assertions.rb +25 -2
  15. data/lib/beaker/dsl/ezbake_utils.rb +2 -2
  16. data/lib/beaker/dsl/helpers.rb +66 -12
  17. data/lib/beaker/dsl/install_utils.rb +128 -66
  18. data/lib/beaker/dsl/wrappers.rb +41 -3
  19. data/lib/beaker/host.rb +42 -6
  20. data/lib/beaker/host/mac.rb +62 -0
  21. data/lib/beaker/host/mac/group.rb +96 -0
  22. data/lib/beaker/host/mac/user.rb +93 -0
  23. data/lib/beaker/host/unix/exec.rb +1 -1
  24. data/lib/beaker/host/unix/pkg.rb +11 -11
  25. data/lib/beaker/host/windows.rb +4 -4
  26. data/lib/beaker/host_prebuilt_steps.rb +194 -58
  27. data/lib/beaker/hypervisor.rb +16 -9
  28. data/lib/beaker/hypervisor/aws_sdk.rb +61 -17
  29. data/lib/beaker/hypervisor/docker.rb +14 -2
  30. data/lib/beaker/hypervisor/ec2_helper.rb +15 -3
  31. data/lib/beaker/hypervisor/vagrant.rb +22 -10
  32. data/lib/beaker/hypervisor/vagrant_libvirt.rb +11 -0
  33. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +1 -1
  34. data/lib/beaker/hypervisor/vcloud_pooled.rb +8 -39
  35. data/lib/beaker/logger.rb +15 -9
  36. data/lib/beaker/network_manager.rb +2 -2
  37. data/lib/beaker/options/command_line_parser.rb +1 -1
  38. data/lib/beaker/options/parser.rb +1 -8
  39. data/lib/beaker/options/presets.rb +70 -45
  40. data/lib/beaker/perf.rb +3 -4
  41. data/lib/beaker/platform.rb +2 -1
  42. data/lib/beaker/result.rb +3 -9
  43. data/lib/beaker/ssh_connection.rb +2 -0
  44. data/lib/beaker/test_case.rb +2 -21
  45. data/lib/beaker/test_suite.rb +21 -25
  46. data/lib/beaker/version.rb +1 -1
  47. data/spec/beaker/answers_spec.rb +36 -0
  48. data/spec/beaker/cli_spec.rb +45 -45
  49. data/spec/beaker/command_spec.rb +25 -36
  50. data/spec/beaker/dsl/assertions_spec.rb +20 -27
  51. data/spec/beaker/dsl/ezbake_utils_spec.rb +5 -5
  52. data/spec/beaker/dsl/helpers_spec.rb +293 -208
  53. data/spec/beaker/dsl/install_utils_spec.rb +310 -189
  54. data/spec/beaker/dsl/outcomes_spec.rb +6 -6
  55. data/spec/beaker/dsl/roles_spec.rb +27 -18
  56. data/spec/beaker/dsl/structure_spec.rb +11 -11
  57. data/spec/beaker/dsl/wrappers_spec.rb +35 -11
  58. data/spec/beaker/host/mac/group_spec.rb +124 -0
  59. data/spec/beaker/host/mac/user_spec.rb +134 -0
  60. data/spec/beaker/host/unix/pkg_spec.rb +40 -24
  61. data/spec/beaker/host/windows/group_spec.rb +1 -1
  62. data/spec/beaker/host_prebuilt_steps_spec.rb +194 -68
  63. data/spec/beaker/host_spec.rb +145 -67
  64. data/spec/beaker/hypervisor/aixer_spec.rb +6 -6
  65. data/spec/beaker/hypervisor/aws_sdk_spec.rb +22 -7
  66. data/spec/beaker/hypervisor/docker_spec.rb +71 -50
  67. data/spec/beaker/hypervisor/ec2_helper_spec.rb +25 -4
  68. data/spec/beaker/hypervisor/fusion_spec.rb +2 -2
  69. data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -27
  70. data/spec/beaker/hypervisor/hypervisor_spec.rb.orig +80 -0
  71. data/spec/beaker/hypervisor/solaris_spec.rb +8 -8
  72. data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +6 -8
  73. data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +34 -0
  74. data/spec/beaker/hypervisor/vagrant_spec.rb +34 -33
  75. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +18 -8
  76. data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +6 -8
  77. data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +8 -8
  78. data/spec/beaker/hypervisor/vcloud_spec.rb +10 -10
  79. data/spec/beaker/hypervisor/vsphere_helper_spec.rb +8 -8
  80. data/spec/beaker/hypervisor/vsphere_spec.rb +1 -1
  81. data/spec/beaker/logger_spec.rb +45 -31
  82. data/spec/beaker/options/command_line_parser_spec.rb +10 -2
  83. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  84. data/spec/beaker/options/options_hash_spec.rb +2 -2
  85. data/spec/beaker/options/parser_spec.rb +2 -2
  86. data/spec/beaker/options/pe_version_scaper_spec.rb +6 -1
  87. data/spec/beaker/options/presets_spec.rb +11 -1
  88. data/spec/beaker/shared/error_handler_spec.rb +5 -5
  89. data/spec/beaker/shared/host_manager_spec.rb +3 -2
  90. data/spec/beaker/shared/repetition_spec.rb +18 -18
  91. data/spec/beaker/ssh_connection_spec.rb +33 -4
  92. data/spec/beaker/test_case_spec.rb +9 -9
  93. data/spec/beaker/test_suite_spec.rb +14 -14
  94. data/spec/helpers.rb +4 -4
  95. data/spec/matchers.rb +4 -4
  96. data/spec/mocks.rb +5 -1
  97. data/spec/spec_helper.rb +2 -8
  98. metadata +114 -80
  99. data/lib/beaker/hypervisor/blimper.rb +0 -108
  100. data/spec/beaker/hypervisor/blimper_spec.rb +0 -42
  101. data/spec/beaker/options/data/LATEST +0 -1
  102. data/spec/beaker/puppet_command_spec.rb +0 -161
  103. data/spec/mock_blimpy.rb +0 -48
@@ -29,40 +29,40 @@ module Beaker
29
29
 
30
30
  it "can be a pe host" do
31
31
  options['type'] = 'pe'
32
- expect(host.is_pe?).to be_true
33
- expect(host.use_service_scripts?).to be_true
34
- expect(host.is_using_passenger?).to be_true
35
- expect(host.graceful_restarts?).to be_false
32
+ expect(host.is_pe?).to be_truthy
33
+ expect(host.use_service_scripts?).to be_truthy
34
+ expect(host.is_using_passenger?).to be_truthy
35
+ expect(host.graceful_restarts?).to be_falsy
36
36
  end
37
37
 
38
38
  it "can be a foss-source host" do
39
- expect(host.is_pe?).to be_false
40
- expect(host.use_service_scripts?).to be_false
41
- expect(host.is_using_passenger?).to be_false
39
+ expect(host.is_pe?).to be_falsy
40
+ expect(host.use_service_scripts?).to be_falsy
41
+ expect(host.is_using_passenger?).to be_falsy
42
42
  end
43
43
 
44
44
  it "can be a foss-package host" do
45
45
  options['use-service'] = true
46
- expect(host.is_pe?).to be_false
47
- expect(host.use_service_scripts?).to be_true
48
- expect(host.is_using_passenger?).to be_false
49
- expect(host.graceful_restarts?).to be_false
46
+ expect(host.is_pe?).to be_falsy
47
+ expect(host.use_service_scripts?).to be_truthy
48
+ expect(host.is_using_passenger?).to be_falsy
49
+ expect(host.graceful_restarts?).to be_falsy
50
50
  end
51
51
 
52
52
  it "can be a foss-packaged host using passenger" do
53
53
  host.uses_passenger!
54
- expect(host.is_pe?).to be_false
55
- expect(host.use_service_scripts?).to be_true
56
- expect(host.is_using_passenger?).to be_true
57
- expect(host.graceful_restarts?).to be_true
54
+ expect(host.is_pe?).to be_falsy
55
+ expect(host.use_service_scripts?).to be_truthy
56
+ expect(host.is_using_passenger?).to be_truthy
57
+ expect(host.graceful_restarts?).to be_truthy
58
58
  end
59
59
  end
60
60
 
61
61
  describe "uses_passenger!" do
62
62
  it "sets passenger property" do
63
63
  host.uses_passenger!
64
- expect(host['passenger']).to be_true
65
- expect(host.is_using_passenger?).to be_true
64
+ expect(host['passenger']).to be_truthy
65
+ expect(host.is_using_passenger?).to be_truthy
66
66
  end
67
67
 
68
68
  it "sets puppetservice" do
@@ -79,28 +79,28 @@ module Beaker
79
79
  describe "graceful_restarts?" do
80
80
  it "is true if graceful-restarts property is set true" do
81
81
  options['graceful-restarts'] = true
82
- expect(host.graceful_restarts?).to be_true
82
+ expect(host.graceful_restarts?).to be_truthy
83
83
  end
84
84
 
85
85
  it "is false if graceful-restarts property is set false" do
86
86
  options['graceful-restarts'] = false
87
- expect(host.graceful_restarts?).to be_false
87
+ expect(host.graceful_restarts?).to be_falsy
88
88
  end
89
89
 
90
90
  it "is false if is_pe and graceful-restarts is nil" do
91
91
  options['type'] = 'pe'
92
- expect(host.graceful_restarts?).to be_false
92
+ expect(host.graceful_restarts?).to be_falsy
93
93
  end
94
94
 
95
95
  it "is true if is_pe and graceful-restarts is true" do
96
96
  options['type'] = 'pe'
97
97
  options['graceful-restarts'] = true
98
- expect(host.graceful_restarts?).to be_true
98
+ expect(host.graceful_restarts?).to be_truthy
99
99
  end
100
100
 
101
101
  it "falls back to passenger property if not pe and graceful-restarts is nil" do
102
102
  host.uses_passenger!
103
- expect(host.graceful_restarts?).to be_true
103
+ expect(host.graceful_restarts?).to be_truthy
104
104
  end
105
105
  end
106
106
 
@@ -112,20 +112,20 @@ module Beaker
112
112
 
113
113
  before(:each) do
114
114
  @platform = 'windows'
115
- host.stub(:check_for_package).and_return(true)
115
+ allow( host ).to receive(:check_for_package).and_return(true)
116
116
  end
117
117
 
118
118
  context "testing osarchitecture" do
119
119
 
120
120
  before(:each) do
121
- host.should_receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(success_osarch_check)
121
+ expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(success_osarch_check)
122
122
  end
123
123
 
124
124
  context "32 bit" do
125
125
  let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '32-bit') }
126
126
 
127
127
  it "uses 32 bit cygwin" do
128
- host.should_receive(:execute).with(/#{cygwin}.*#{package}/)
128
+ expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
129
129
  host.install_package(package)
130
130
  end
131
131
  end
@@ -134,7 +134,7 @@ module Beaker
134
134
  let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '64-bit') }
135
135
 
136
136
  it "uses 64 bit cygwin" do
137
- host.should_receive(:execute).with(/#{cygwin64}.*#{package}/)
137
+ expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
138
138
  host.install_package(package)
139
139
  end
140
140
  end
@@ -144,15 +144,15 @@ module Beaker
144
144
  let(:failed_osarch_check) { double(:failed, :exit_code => 1) }
145
145
 
146
146
  before(:each) do
147
- host.should_receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(failed_osarch_check)
148
- host.should_receive(:execute).with(/wmic os get name/, anything).and_yield(name_check)
147
+ expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(failed_osarch_check)
148
+ expect( host ).to receive(:execute).with(/wmic os get name/, anything).and_yield(name_check)
149
149
  end
150
150
 
151
151
  context "32 bit" do
152
152
  let(:name_check) { double(:failure, :exit_code => 1) }
153
153
 
154
154
  it "uses 32 bit cygwin" do
155
- host.should_receive(:execute).with(/#{cygwin}.*#{package}/)
155
+ expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
156
156
  host.install_package(package)
157
157
  end
158
158
  end
@@ -161,7 +161,7 @@ module Beaker
161
161
  let(:name_check) { double(:success, :exit_code => 0) }
162
162
 
163
163
  it "uses 64 bit cygwin" do
164
- host.should_receive(:execute).with(/#{cygwin64}.*#{package}/)
164
+ expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
165
165
  host.install_package(package)
166
166
  end
167
167
  end
@@ -169,6 +169,52 @@ module Beaker
169
169
  end
170
170
  end
171
171
 
172
+ describe "#add_env_var" do
173
+
174
+ it "does nothing if the key/value pair already exists" do
175
+ result = Beaker::Result.new(host, '')
176
+ result.exit_code = 0
177
+ expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
178
+ expect( host ).to receive(:exec).once.and_return(result)
179
+
180
+ host.add_env_var('key', '/my/first/value')
181
+ end
182
+
183
+ it "adds new line to environment file if no env var of that name already exists" do
184
+ result = Beaker::Result.new(host, '')
185
+ result.exit_code = 1
186
+ expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
187
+ expect( host ).to receive(:exec).and_return(result)
188
+ expect( Beaker::Command ).to receive(:new).with(/grep KEY ~\/\.ssh\/environment/)
189
+ expect( host ).to receive(:exec).and_return(result)
190
+ expect( Beaker::Command ).to receive(:new).with("echo \"KEY=/my/first/value\" >> ~/.ssh/environment")
191
+ host.add_env_var('key', '/my/first/value')
192
+ end
193
+
194
+ it "updates existing line in environment file when adding additional value to existing variable" do
195
+ result = Beaker::Result.new(host, '')
196
+ result.exit_code = 1
197
+ expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
198
+ expect( host ).to receive(:exec).and_return(result)
199
+ result = Beaker::Result.new(host, '')
200
+ result.exit_code = 0
201
+ expect( Beaker::Command ).to receive(:new).with(/grep KEY ~\/\.ssh\/environment/)
202
+ expect( host ).to receive(:exec).and_return(result)
203
+ expect( Beaker::Command ).to receive(:new).with("sed -i -e \"s/KEY=/KEY=\\/my\\/first\\/value:/\" ~/.ssh/environment")
204
+ host.add_env_var('key', '/my/first/value')
205
+ end
206
+
207
+ end
208
+
209
+ describe "#delete_env_var" do
210
+ it "deletes env var" do
211
+ expect( Beaker::Command ).to receive(:new).with("sed -i -e \"/key=\\/my\\/first\\/value$/d\" ~/.ssh/environment")
212
+ expect( Beaker::Command ).to receive(:new).with("sed -i -e \"s/key=\\(.*[:;]*\\)\\/my\\/first\\/value[:;]*/key=\\1/\" ~/.ssh/environment")
213
+ host.delete_env_var('key', '/my/first/value')
214
+ end
215
+
216
+ end
217
+
172
218
  describe "executing commands" do
173
219
  let(:command) { Beaker::Command.new('ls') }
174
220
  let(:host) { Beaker::Host.create('host', make_host_opts('host', options.merge(platform))) }
@@ -179,11 +225,11 @@ module Beaker
179
225
  result.stderr = 'stderr'
180
226
 
181
227
  logger = double(:logger)
182
- logger.stub(:host_output)
183
- logger.stub(:debug)
228
+ allow( logger ).to receive(:host_output)
229
+ allow( logger ).to receive(:debug)
184
230
  host.instance_variable_set :@logger, logger
185
231
  conn = double(:connection)
186
- conn.stub(:execute).and_return(result)
232
+ allow( conn ).to receive(:execute).and_return(result)
187
233
  host.instance_variable_set :@connection, conn
188
234
  end
189
235
 
@@ -200,6 +246,33 @@ module Beaker
200
246
  host.exec(command,{})
201
247
  end
202
248
 
249
+ it 'raises a CommandFailure when an unacceptable exit code is returned' do
250
+ result.exit_code = 7
251
+ opts = { :acceptable_exit_codes => [0, 1] }
252
+
253
+ expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
254
+ end
255
+
256
+ it 'raises a CommandFailure when an unacceptable exit code is returned and the accept_all_exit_codes flag is set to false' do
257
+ result.exit_code = 7
258
+ opts = {
259
+ :acceptable_exit_codes => [0, 1],
260
+ :accept_all_exit_codes => false
261
+ }
262
+
263
+ expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
264
+ end
265
+
266
+ it 'does not throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
267
+ result.exit_code = 7
268
+ opts = {
269
+ :acceptable_exit_codes => [0, 1],
270
+ :accept_all_exit_codes => true
271
+ }
272
+
273
+ expect { host.exec(command, opts) }.to_not raise_error
274
+ end
275
+
203
276
  context "controls the result objects logging" do
204
277
  it "and passes a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
205
278
  result.exit_code = 0
@@ -232,7 +305,7 @@ module Beaker
232
305
  # it takes a location and a destination
233
306
  # it basically proxies that to the connection object
234
307
  it 'do_scp_to logs info and proxies to the connection' do
235
- File.stub(:file?).and_return(true)
308
+ create_files(['source'])
236
309
  logger = host[:logger]
237
310
  conn = double(:connection)
238
311
  @options = { :logger => logger }
@@ -240,15 +313,20 @@ module Beaker
240
313
  args = [ 'source', 'target', {} ]
241
314
  conn_args = args + [ nil ]
242
315
 
243
- logger.should_receive(:trace)
244
- conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
316
+ expect( logger ).to receive(:trace)
317
+ expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
245
318
 
246
319
  host.do_scp_to *args
247
320
  end
248
321
 
322
+ it 'throws an IOError when the file given doesn\'t exist' do
323
+ expect { host.do_scp_to "/does/not/exist", "does/not/exist/over/there", {} }.to raise_error(IOError)
324
+ end
325
+
249
326
  context "using an ignore array with an absolute source path" do
250
- source_path = '/repos/puppetlabs-inifile'
251
- target_path = '/etc/puppetlabs/modules/inifile'
327
+ let( :source_path ) { '/repos/puppetlabs-inifile' }
328
+ let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
329
+
252
330
  before :each do
253
331
  test_dir = "#{source_path}/tests"
254
332
  other_test_dir = "#{source_path}/tests2"
@@ -265,20 +343,20 @@ module Beaker
265
343
  create_files( @fileset1 )
266
344
  create_files( @fileset2 )
267
345
  end
268
- it 'can take an ignore list that excludes all files and not call scp_to', :use_fakefs => true do
346
+ it 'can take an ignore list that excludes all files and not call scp_to' do
269
347
  logger = host[:logger]
270
348
  conn = double(:connection)
271
349
  @options = { :logger => logger }
272
350
  host.instance_variable_set :@connection, conn
273
351
  args = [ source_path, target_path, {:ignore => ['tests', 'tests2']} ]
274
352
 
275
- logger.should_receive(:trace)
276
- host.should_receive( :mkdir_p ).exactly(0).times
277
- conn.should_receive(:scp_to).exactly(0).times
353
+ expect( logger ).to receive(:trace)
354
+ expect( host ).to receive( :mkdir_p ).exactly(0).times
355
+ expect( conn ).to receive(:scp_to).exactly(0).times
278
356
 
279
357
  host.do_scp_to *args
280
358
  end
281
- it 'can take an ignore list that excludes a single file and scp the rest', :use_fakefs => true do
359
+ it 'can take an ignore list that excludes a single file and scp the rest' do
282
360
  exclude_file = '07_InstallCACerts.rb'
283
361
  logger = host[:logger]
284
362
  conn = double(:connection)
@@ -286,20 +364,21 @@ module Beaker
286
364
  host.instance_variable_set :@connection, conn
287
365
  args = [ source_path, target_path, {:ignore => [exclude_file]} ]
288
366
 
289
- Dir.stub( :glob ).and_return( @fileset1 + @fileset2 )
367
+ allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
368
+
369
+ expect( logger ).to receive(:trace)
370
+ expect( host ).to receive( :mkdir_p ).with("#{target_path}/tests")
371
+ expect( host ).to receive( :mkdir_p ).with("#{target_path}/tests2")
290
372
 
291
- logger.should_receive(:trace)
292
- host.should_receive( :mkdir_p ).with("#{target_path}/tests")
293
- host.should_receive( :mkdir_p ).with("#{target_path}/tests2")
294
373
  (@fileset1 + @fileset2).each do |file|
295
374
  if file !~ /#{exclude_file}/
296
375
  file_args = [ file, File.join(target_path, file.gsub(source_path,'')), {:ignore => [exclude_file]} ]
297
376
  conn_args = file_args + [ nil ]
298
- conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
377
+ expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
299
378
  else
300
379
  file_args = [ file, File.join(target_path, file.gsub(source_path,'')), {:ignore => [exclude_file]} ]
301
380
  conn_args = file_args + [ nil ]
302
- conn.should_not_receive(:scp_to).with( *conn_args )
381
+ expect( conn ).to_not receive(:scp_to).with( *conn_args )
303
382
  end
304
383
  end
305
384
 
@@ -325,21 +404,21 @@ module Beaker
325
404
  create_files( @fileset2 )
326
405
  end
327
406
 
328
- it 'can take an ignore list that excludes all files and not call scp_to', :use_fakefs => true do
407
+ it 'can take an ignore list that excludes all files and not call scp_to' do
329
408
  logger = host[:logger]
330
409
  conn = double(:connection)
331
410
  @options = { :logger => logger }
332
411
  host.instance_variable_set :@connection, conn
333
412
  args = [ 'tmp', 'target', {:ignore => ['tests', 'tests2']} ]
334
413
 
335
- logger.should_receive(:trace)
336
- host.should_receive( :mkdir_p ).exactly(0).times
337
- conn.should_receive(:scp_to).exactly(0).times
414
+ expect( logger ).to receive(:trace)
415
+ expect( host ).to receive( :mkdir_p ).exactly(0).times
416
+ expect( conn ).to receive(:scp_to).exactly(0).times
338
417
 
339
418
  host.do_scp_to *args
340
419
  end
341
420
 
342
- it 'can take an ignore list that excludes a single file and scp the rest', :use_fakefs => true do
421
+ it 'can take an ignore list that excludes a single file and scp the rest' do
343
422
  exclude_file = '07_InstallCACerts.rb'
344
423
  logger = host[:logger]
345
424
  conn = double(:connection)
@@ -347,23 +426,23 @@ module Beaker
347
426
  host.instance_variable_set :@connection, conn
348
427
  args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
349
428
 
350
- Dir.stub( :glob ).and_return( @fileset1 + @fileset2 )
429
+ allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
351
430
 
352
- logger.should_receive(:trace)
353
- host.should_receive( :mkdir_p ).with('target/tmp/tests')
354
- host.should_receive( :mkdir_p ).with('target/tmp/tests2')
431
+ expect( logger ).to receive(:trace)
432
+ expect( host ).to receive( :mkdir_p ).with('target/tmp/tests')
433
+ expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
355
434
  (@fileset1 + @fileset2).each do |file|
356
435
  if file !~ /#{exclude_file}/
357
436
  file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
358
437
  conn_args = file_args + [ nil ]
359
- conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
438
+ expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
360
439
  end
361
440
  end
362
441
 
363
442
  host.do_scp_to *args
364
443
  end
365
444
 
366
- it 'can take an ignore list that excludes a dir and scp the rest', :use_fakefs => true do
445
+ it 'can take an ignore list that excludes a dir and scp the rest' do
367
446
  exclude_file = 'tests'
368
447
  logger = host[:logger]
369
448
  conn = double(:connection)
@@ -371,14 +450,14 @@ module Beaker
371
450
  host.instance_variable_set :@connection, conn
372
451
  args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
373
452
 
374
- Dir.stub( :glob ).and_return( @fileset1 + @fileset2 )
453
+ allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
375
454
 
376
- logger.should_receive(:trace)
377
- host.should_receive( :mkdir_p ).with('target/tmp/tests2')
455
+ expect( logger ).to receive(:trace)
456
+ expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
378
457
  (@fileset2).each do |file|
379
458
  file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
380
459
  conn_args = file_args + [ nil ]
381
- conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
460
+ expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
382
461
  end
383
462
 
384
463
  host.do_scp_to *args
@@ -395,8 +474,8 @@ module Beaker
395
474
  args = [ 'source', 'target', {} ]
396
475
  conn_args = args + [ nil ]
397
476
 
398
- logger.should_receive(:debug)
399
- conn.should_receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
477
+ expect( logger ).to receive(:debug)
478
+ expect( conn ).to receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
400
479
 
401
480
  host.do_scp_from *args
402
481
  end
@@ -413,6 +492,5 @@ module Beaker
413
492
  end
414
493
 
415
494
  end
416
-
417
495
  end
418
496
  end
@@ -6,14 +6,14 @@ module Beaker
6
6
 
7
7
  before :each do
8
8
  @hosts = make_hosts()
9
- File.stub( :exists? ).and_return( true )
10
- YAML.stub( :load_file ).and_return( fog_file_contents )
11
- Host.any_instance.stub( :exec ).and_return( true )
9
+ allow( File ).to receive( :exists? ).and_return( true )
10
+ allow( YAML ).to receive( :load_file ).and_return( fog_file_contents )
11
+ allow_any_instance_of( Host ).to receive( :exec ).and_return( true )
12
12
  end
13
13
 
14
14
  it "can provision a set of hosts" do
15
15
  @hosts.each do |host|
16
- Command.should_receive( :new ).with( "cd pe-aix && rake restore:#{host.name}" ).once
16
+ expect( Command ).to receive( :new ).with( "cd pe-aix && rake restore:#{host.name}" ).once
17
17
 
18
18
  end
19
19
 
@@ -22,8 +22,8 @@ module Beaker
22
22
  end
23
23
 
24
24
  it "does nothing for cleanup" do
25
- Command.should_receive( :new ).never
26
- Host.should_receive( :exec ).never
25
+ expect( Command ).to receive( :new ).never
26
+ expect( Host ).to receive( :exec ).never
27
27
 
28
28
  aixer.cleanup
29
29