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
@@ -42,53 +42,42 @@ module Beaker
42
42
  end
43
43
 
44
44
  describe '#environment_string_for' do
45
+ let(:host) { {'pathseparator' => ':'} }
46
+
45
47
  it 'returns a blank string if theres no env' do
46
- expect( subject.environment_string_for({}, {}) ).to be == ''
48
+ expect( subject.environment_string_for(host, {}) ).to be == ''
47
49
  end
48
50
 
49
51
  it 'takes an env hash with var_name/value pairs' do
50
- expect( subject.environment_string_for({}, {:HOME => '/'}) ).
51
- to be == 'env HOME="/"'
52
+ expect( subject.environment_string_for(host, {:HOME => '/'}) ).
53
+ to be == "env HOME=\"/\""
52
54
  end
53
55
 
54
56
  it 'takes an env hash with var_name/value[Array] pairs' do
55
- expect( subject.environment_string_for({}, {:LD_PATH => ['/', '/tmp']}) ).
56
- to be == 'env LD_PATH="/:/tmp"'
57
- end
58
-
59
- it 'takes var_names where there is an array of default values' do
60
- env = {:PATH => { :default => [ '/bin', '/usr/bin' ] } }
61
- expect( subject.environment_string_for({}, env) ).
62
- to be == 'env PATH="/bin:/usr/bin"'
63
-
57
+ expect( subject.environment_string_for(host, {:LD_PATH => ['/', '/tmp']}) ).
58
+ to be == "env LD_PATH=\"/:/tmp\""
64
59
  end
60
+ end
65
61
 
66
- it 'takes var_names where there is an array of host specific values' do
67
- host = { 'pe_path' => '/opt/puppet/bin', 'foss_path' => '/usr/bin' }
68
- env = {:PATH => { :host => [ 'pe_path', 'foss_path' ] } }
69
- expect( subject.environment_string_for( host, env ) ).
70
- to be == 'env PATH="/opt/puppet/bin:/usr/bin"'
62
+ end
63
+ describe HostCommand do
64
+ let(:command) { @command || '/bin/ls' }
65
+ let(:args) { @args || Array.new }
66
+ let(:options) { @options || Hash.new }
67
+ subject(:cmd) { HostCommand.new( command, args, options ) }
68
+ let(:host) { Hash.new }
71
69
 
72
- end
73
- it 'when using an array of values it allows to specify the separator' do
74
- host = { 'whoosits_separator' => ' **sparkles** ' }
75
- env = {
76
- :WHOOSITS => {
77
- :default => [ 'whatsits', 'wonkers' ],
78
- :opts => {:separator => {:host => 'whoosits_separator' } }
79
- }
80
- }
81
- expect( subject.environment_string_for( host, env ) ).
82
- to be == 'env WHOOSITS="whatsits **sparkles** wonkers"'
83
- end
70
+ it 'returns a simple string passed in' do
71
+ @command = "pants"
72
+ expect( cmd.cmd_line host ).to be === @command
84
73
  end
85
-
86
- describe '#parse_env_hash_for' do
87
- it 'has too many responsiblities' do
88
- env = { :PATH => { :default => [ '/bin', '/usr/bin' ] } }
89
- var_array = cmd.parse_env_hash_for host, env
90
- expect( var_array ).to be == [ 'PATH="/bin:/usr/bin"' ]
91
- end
74
+ it 'returns single quoted string correctly' do
75
+ @command = "str_p = 'pants'; str_p"
76
+ expect( cmd.cmd_line host ).to be === @command
77
+ end
78
+ it 'returns empty strings when given the escaped version of the same' do
79
+ @command = "\"\""
80
+ expect( cmd.cmd_line host ).to be === ""
92
81
  end
93
82
  end
94
83
  end
@@ -20,12 +20,12 @@ CONSOLE
20
20
  CONSOLE
21
21
 
22
22
  result = double
23
- result.should_receive( :nil? ).at_least( :once ).and_return( false )
24
- result.should_receive( :stdout ).and_return( stdout )
25
- result.should_receive( :output ).and_return( stdout )
26
- result.should_receive( :stderr ).and_return( '' )
23
+ expect( result ).to receive( :nil? ).at_least( :once ).and_return( false )
24
+ expect( result ).to receive( :stdout ).and_return( stdout )
25
+ expect( result ).to receive( :output ).and_return( stdout )
26
+ expect( result ).to receive( :stderr ).and_return( '' )
27
27
 
28
- subject.should_receive( :result ).at_least( :once ).and_return( result )
28
+ expect( subject ).to receive( :result ).at_least( :once ).and_return( result )
29
29
  expect { subject.assert_output expectation }.to_not raise_error
30
30
  end
31
31
 
@@ -52,51 +52,44 @@ STDERR
52
52
  EXPECT
53
53
 
54
54
  result = double
55
- result.should_receive( :nil? ).at_least( :once ).and_return( false )
56
- result.should_receive( :stdout ).and_return( stdout )
57
- result.should_receive( :output ).and_return( output )
58
- result.should_receive( :stderr ).and_return( stderr )
55
+ expect( result ).to receive( :nil? ).at_least( :once ).and_return( false )
56
+ expect( result ).to receive( :stdout ).and_return( stdout )
57
+ expect( result ).to receive( :output ).and_return( output )
58
+ expect( result ).to receive( :stderr ).and_return( stderr )
59
59
 
60
- subject.should_receive( :result ).at_least( :once ).and_return( result )
60
+ expect( subject ).to receive( :result ).at_least( :once ).and_return( result )
61
61
  expect { subject.assert_output expectation }.to_not raise_error
62
62
  end
63
63
 
64
64
  it 'raises an approriate error when output does not match expectations' do
65
- output = <<OUTPUT
65
+ FakeFS.without do
66
+ output = <<OUTPUT
66
67
  This is on stdout
67
68
  Holy Crap, what HAPPENED!?!?!?
68
69
  And THIS is again on stdout
69
70
  OUTPUT
70
71
 
71
- stdout = <<STDOUT
72
+ stdout = <<STDOUT
72
73
  This is on stdout
73
74
  And THIS is again on stdout
74
75
  STDOUT
75
76
 
76
- stderr = <<STDERR
77
+ stderr = <<STDERR
77
78
  Holy Crap, what HAPPENED!?!?!?
78
79
  STDERR
79
80
 
80
- expectation = <<EXPECT
81
+ expectation = <<EXPECT
81
82
  STDOUT> This is on stdout
82
83
  STDERR> While this is on stderr
83
84
  STDOUT> And THIS is again on stdout
84
85
  EXPECT
86
+ result = double
87
+ expect( result ).to receive( :nil? ).at_least( :once ).and_return( false )
88
+ expect( result ).to receive( :output ).and_return( output )
85
89
 
86
- require 'rbconfig'
87
- ruby_conf = defined?(RbConfig) ? RbConfig::CONFIG : Config::CONFIG
88
- if ruby_conf['MINOR'].to_i == 8
89
- exception = Test::Unit::AssertionFailedError
90
- else
91
- exception = MiniTest::Assertion
90
+ expect( subject ).to receive( :result ).at_least( :once ).and_return( result )
91
+ expect { subject.assert_output expectation }.to raise_error( MiniTest::Assertion )
92
92
  end
93
-
94
- result = double
95
- result.should_receive( :nil? ).at_least( :once ).and_return( false )
96
- result.should_receive( :output ).and_return( output )
97
-
98
- subject.should_receive( :result ).at_least( :once ).and_return( result )
99
- expect { subject.assert_output expectation }.to raise_error( exception )
100
93
  end
101
94
  end
102
95
  end
@@ -25,7 +25,7 @@ class ClassMixedWithEZBakeUtils
25
25
  end
26
26
 
27
27
  def logger
28
- @logger ||= RSpec::Mocks::Mock.new('logger').as_null_object
28
+ @logger ||= RSpec::Mocks::Double.new('logger').as_null_object
29
29
  end
30
30
  end
31
31
 
@@ -107,7 +107,7 @@ describe ClassMixedWithEZBakeUtils do
107
107
  end
108
108
 
109
109
  it "initializes EZBakeUtils.config" do
110
- Dir.stub( :chdir ).and_yield()
110
+ allow( Dir ).to receive( :chdir ).and_yield()
111
111
  allow(subject).to receive(:conditionally_clone) { true }
112
112
 
113
113
  expect(subject).to receive(:`).with(/^lein.*/).ordered
@@ -191,7 +191,7 @@ describe ClassMixedWithEZBakeUtils do
191
191
  end
192
192
 
193
193
  it "raises an exception for unsupported *nix-like platforms" do
194
- Dir.stub( :chdir ).and_yield()
194
+ allow( Dir ).to receive( :chdir ).and_yield()
195
195
  install_from_ezbake_common_expects
196
196
  expect{
197
197
  subject.install_from_ezbake host, "blah", "blah"
@@ -201,7 +201,7 @@ describe ClassMixedWithEZBakeUtils do
201
201
  context "When Beaker::DSL::EZBakeUtils.config is nil" do
202
202
  let( :platform ) { Beaker::Platform.new('el-7-i386') }
203
203
  before do
204
- Dir.stub( :chdir ).and_yield()
204
+ allow( Dir ).to receive( :chdir ).and_yield()
205
205
  subject.wipe_out_ezbake_config
206
206
  end
207
207
 
@@ -220,7 +220,7 @@ describe ClassMixedWithEZBakeUtils do
220
220
  context "When Beaker::DSL::EZBakeUtils.config is a hash" do
221
221
  let( :platform ) { Beaker::Platform.new('el-7-i386') }
222
222
  before do
223
- Dir.stub( :chdir ).and_yield()
223
+ allow( Dir ).to receive( :chdir ).and_yield()
224
224
  subject.initialize_ezbake_config
225
225
  end
226
226
 
@@ -7,14 +7,15 @@ class ClassMixedWithDSLHelpers
7
7
  include Beaker::DSL::Patterns
8
8
 
9
9
  def logger
10
- @logger ||= RSpec::Mocks::Mock.new('logger').as_null_object
10
+ RSpec::Mocks::Double.new('logger').as_null_object
11
11
  end
12
+
12
13
  end
13
14
 
14
15
  describe ClassMixedWithDSLHelpers do
15
- let( :opts ) { Beaker::Options::Presets.env_vars }
16
- let( :command ) { 'ls' }
17
- let( :host ) { double.as_null_object }
16
+ let( :opts ) { Beaker::Options::Presets.env_vars }
17
+ let( :command ){ 'ls' }
18
+ let( :host ) { double.as_null_object }
18
19
  let( :result ) { Beaker::Result.new( host, command ) }
19
20
 
20
21
  let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
@@ -22,7 +23,7 @@ describe ClassMixedWithDSLHelpers do
22
23
  let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
23
24
  let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
24
25
  let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
25
- let( :hosts ) { [ master, agent, dash, db, custom ] }
26
+ let( :hosts ) { [ master, agent, dash, db, custom ] }
26
27
 
27
28
  describe '#on' do
28
29
 
@@ -33,38 +34,38 @@ describe ClassMixedWithDSLHelpers do
33
34
  end
34
35
 
35
36
  it 'allows the environment the command is run within to be specified' do
36
- subject.stub( :hosts ).and_return( hosts )
37
+ allow( subject ).to receive( :hosts ).and_return( hosts )
37
38
 
38
- Beaker::Command.should_receive( :new ).
39
+ expect( Beaker::Command ).to receive( :new ).
39
40
  with( 'ls ~/.bin', [], {'ENV' => { :HOME => '/tmp/test_home' }} )
40
41
 
41
42
  subject.on( host, 'ls ~/.bin', :environment => {:HOME => '/tmp/test_home' } )
42
43
  end
43
44
 
44
45
  it 'if the host is a String Object, finds the matching hosts with that String as role' do
45
- subject.stub( :hosts ).and_return( hosts )
46
+ allow( subject ).to receive( :hosts ).and_return( hosts )
46
47
 
47
- master.should_receive( :exec ).once
48
+ expect( master ).to receive( :exec ).once
48
49
 
49
50
  subject.on( 'master', 'echo hello')
50
51
 
51
52
  end
52
53
 
53
54
  it 'if the host is a Symbol Object, finds the matching hsots with that Symbol as role' do
54
- subject.stub( :hosts ).and_return( hosts )
55
+ allow( subject ).to receive( :hosts ).and_return( hosts )
55
56
 
56
- master.should_receive( :exec ).once
57
+ expect( master ).to receive( :exec ).once
57
58
 
58
59
  subject.on( :master, 'echo hello')
59
60
 
60
61
  end
61
62
 
62
63
  it 'delegates to itself for each host passed' do
63
- subject.stub( :hosts ).and_return( hosts )
64
+ allow( subject ).to receive( :hosts ).and_return( hosts )
64
65
  expected = []
65
66
  hosts.each_with_index do |host, i|
66
67
  expected << i
67
- host.should_receive( :exec ).and_return( i )
68
+ expect( host ).to receive( :exec ).and_return( i )
68
69
  end
69
70
 
70
71
  results = subject.on( hosts, command )
@@ -73,8 +74,8 @@ describe ClassMixedWithDSLHelpers do
73
74
 
74
75
  context 'upon command completion' do
75
76
  before :each do
76
- subject.stub( :hosts ).and_return( hosts )
77
- host.should_receive( :exec ).and_return( result )
77
+ allow( subject ).to receive( :hosts ).and_return( hosts )
78
+ expect( host ).to receive( :exec ).and_return( result )
78
79
  @res = subject.on( host, command )
79
80
  end
80
81
 
@@ -97,8 +98,8 @@ describe ClassMixedWithDSLHelpers do
97
98
 
98
99
  context 'when passed a block with arity of 1' do
99
100
  before :each do
100
- subject.stub( :hosts ).and_return( hosts )
101
- host.should_receive( :exec ).and_return( result )
101
+ allow( subject ).to receive( :hosts ).and_return( hosts )
102
+ expect( host ).to receive( :exec ).and_return( result )
102
103
  end
103
104
 
104
105
  it 'yields result' do
@@ -129,8 +130,8 @@ describe ClassMixedWithDSLHelpers do
129
130
 
130
131
  context 'when passed a block with arity of 0' do
131
132
  before :each do
132
- subject.stub( :hosts ).and_return( hosts )
133
- host.should_receive( :exec ).and_return( result )
133
+ allow( subject ).to receive( :hosts ).and_return( hosts )
134
+ expect( host ).to receive( :exec ).and_return( result )
134
135
  end
135
136
 
136
137
  it 'yields self' do
@@ -161,11 +162,69 @@ describe ClassMixedWithDSLHelpers do
161
162
 
162
163
  end
163
164
 
165
+ describe "#retry_on" do
166
+ it 'fails correctly when command never succeeds' do
167
+ result.stdout = 'stdout'
168
+ result.stderr = 'stderr'
169
+ result.exit_code = 1
170
+
171
+ retries = 5
172
+
173
+ opts = {
174
+ :max_retries => retries,
175
+ :retry_interval => 0.0001,
176
+ }
177
+
178
+ allow( subject ).to receive(:on).and_return(result)
179
+ expect( subject ).to receive(:on).exactly(retries+2)
180
+ expect { subject.retry_on(host, command, opts) }.to raise_error(RuntimeError)
181
+ end
182
+
183
+ it 'will return success correctly if it succeeds the first time' do
184
+ result.stdout = 'stdout'
185
+ result.stderr = 'stderr'
186
+ result.exit_code = 0
187
+
188
+ opts = {
189
+ :max_retries => 5,
190
+ :retry_interval => 0.0001,
191
+ }
192
+
193
+ allow( subject ).to receive(:on).and_return(result)
194
+ expect( subject ).to receive(:on).once
195
+
196
+ result_given = subject.retry_on(host, command, opts)
197
+ expect(result_given.exit_code).to be === 0
198
+ end
199
+
200
+ it 'will return success correctly if it succeeds after failing a few times' do
201
+ result.stdout = 'stdout'
202
+ result.stderr = 'stderr'
203
+
204
+ opts = {
205
+ :max_retries => 10,
206
+ :retry_interval => 0.1,
207
+ }
208
+
209
+ reps_num = 4
210
+ count = 0
211
+ allow( subject ).to receive(:on) do
212
+ result.exit_code = count > reps_num ? 0 : 1
213
+ count += 1
214
+ result
215
+ end
216
+ expect( subject ).to receive(:on).exactly(reps_num + 2)
217
+
218
+ result_given = subject.retry_on(host, command, opts)
219
+ expect(result_given.exit_code).to be === 0
220
+ end
221
+ end
222
+
164
223
  describe "shell" do
165
224
  it 'delegates to #on with the default host' do
166
- subject.stub( :hosts ).and_return( hosts )
225
+ allow( subject ).to receive( :hosts ).and_return( hosts )
167
226
 
168
- subject.should_receive( :on ).with( master, "echo hello", {}).once
227
+ expect( subject ).to receive( :on ).with( master, "echo hello", {}).once
169
228
 
170
229
  subject.shell( "echo hello" )
171
230
  end
@@ -173,12 +232,12 @@ describe ClassMixedWithDSLHelpers do
173
232
 
174
233
  describe '#scp_from' do
175
234
  it 'delegates to the host' do
176
- subject.stub( :hosts ).and_return( hosts )
177
- subject.should_receive( :logger ).exactly( hosts.length ).times
178
- result.should_receive( :log ).exactly( hosts.length ).times
235
+ allow( subject ).to receive( :hosts ).and_return( hosts )
236
+ expect( subject ).to receive( :logger ).exactly( hosts.length ).times
237
+ expect( result ).to receive( :log ).exactly( hosts.length ).times
179
238
 
180
239
  hosts.each do |host|
181
- host.should_receive( :do_scp_from ).and_return( result )
240
+ expect( host ).to receive( :do_scp_from ).and_return( result )
182
241
  end
183
242
 
184
243
  subject.scp_from( hosts, '/var/log/my.log', 'log/my.log' )
@@ -187,12 +246,12 @@ describe ClassMixedWithDSLHelpers do
187
246
 
188
247
  describe '#scp_to' do
189
248
  it 'delegates to the host' do
190
- subject.stub( :hosts ).and_return( hosts )
191
- subject.should_receive( :logger ).exactly( hosts.length ).times
192
- result.should_receive( :log ).exactly( hosts.length ).times
249
+ allow( subject ).to receive( :hosts ).and_return( hosts )
250
+ expect( subject ).to receive( :logger ).exactly( hosts.length ).times
251
+ expect( result ).to receive( :log ).exactly( hosts.length ).times
193
252
 
194
253
  hosts.each do |host|
195
- host.should_receive( :do_scp_to ).and_return( result )
254
+ expect( host ).to receive( :do_scp_to ).and_return( result )
196
255
  end
197
256
 
198
257
  subject.scp_to( hosts, '/var/log/my.log', 'log/my.log' )
@@ -204,14 +263,14 @@ describe ClassMixedWithDSLHelpers do
204
263
  my_opts = { :silent => true }
205
264
  tmpfile = double
206
265
 
207
- tmpfile.should_receive( :path ).exactly( 2 ).times.
266
+ expect( tmpfile ).to receive( :path ).exactly( 2 ).times.
208
267
  and_return( '/local/path/to/blah' )
209
268
 
210
- Tempfile.should_receive( :open ).and_yield( tmpfile )
269
+ expect( Tempfile ).to receive( :open ).and_yield( tmpfile )
211
270
 
212
- File.should_receive( :open )
271
+ expect( File ).to receive( :open )
213
272
 
214
- subject.should_receive( :scp_to ).
273
+ expect( subject ).to receive( :scp_to ).
215
274
  with( hosts, '/local/path/to/blah', '/remote/path', my_opts )
216
275
 
217
276
  subject.create_remote_file( hosts, '/remote/path', 'blah', my_opts )
@@ -219,7 +278,7 @@ describe ClassMixedWithDSLHelpers do
219
278
  end
220
279
 
221
280
  describe '#create_tmpdir_for_user' do
222
- let(:host) { double.as_null_object }
281
+ let(:host) { {} }
223
282
  let(:result) { double.as_null_object }
224
283
 
225
284
  before :each do
@@ -233,9 +292,10 @@ describe ClassMixedWithDSLHelpers do
233
292
  context 'with no path name argument' do
234
293
  context 'without puppet installed on host' do
235
294
  it 'raises an error' do
236
- allow(host).to receive(:tmpdir).and_return("tmpdirname")
295
+ cmd = "the command"
237
296
  allow(result).to receive(:exit_code).and_return(1)
238
- expect(subject).to receive(:on).with(host, /^puppet.*/).and_return(result)
297
+ expect(Beaker::Command).to receive(:new).with(/puppet master --configprint user/, [], {"ENV"=>{}, :cmdexe=>true}).and_return(cmd)
298
+ expect(subject).to receive(:on).with(host, cmd).and_return(result)
239
299
  expect{
240
300
  subject.create_tmpdir_for_user host
241
301
  }.to raise_error(RuntimeError, /`puppet master --configprint` failed,/)
@@ -243,7 +303,9 @@ describe ClassMixedWithDSLHelpers do
243
303
  end
244
304
  context 'with puppet installed on host' do
245
305
  it 'executes chown once' do
246
- expect(subject).to receive(:on).with(host, /^puppet.*/).and_return(result)
306
+ cmd = "the command"
307
+ expect(Beaker::Command).to receive(:new).with(/puppet master --configprint user/, [], {"ENV"=>{}, :cmdexe=>true}).and_return(cmd)
308
+ expect(subject).to receive(:on).with(host, cmd).and_return(result)
247
309
  expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result)
248
310
  expect(host).to receive(:tmpdir).with(/\/tmp\/beaker.*/)
249
311
  expect(subject).to receive(:on).with(host, /chown puppet.puppet.*/)
@@ -254,7 +316,9 @@ describe ClassMixedWithDSLHelpers do
254
316
 
255
317
  context 'with path name argument' do
256
318
  it 'executes chown once' do
257
- expect(subject).to receive(:on).with(host, /^puppet.*/).and_return(result)
319
+ cmd = "the command"
320
+ expect(Beaker::Command).to receive(:new).with(/puppet master --configprint user/, [], {"ENV"=>{}, :cmdexe=>true}).and_return(cmd)
321
+ expect(subject).to receive(:on).with(host, cmd).and_return(result)
258
322
  expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result)
259
323
  expect(host).to receive(:tmpdir).with(/\/tmp\/bogus.*/).and_return("/tmp/bogus")
260
324
  expect(subject).to receive(:on).with(host, /chown puppet.puppet \/tmp\/bogus.*/)
@@ -288,17 +352,17 @@ describe ClassMixedWithDSLHelpers do
288
352
 
289
353
  describe '#run_script_on' do
290
354
  it 'scps the script to a tmpdir and executes it on host(s)' do
291
- subject.should_receive( :scp_to )
292
- subject.should_receive( :on )
355
+ expect( subject ).to receive( :scp_to )
356
+ expect( subject ).to receive( :on )
293
357
  subject.run_script_on( 'host', '~/.bin/make-enterprisy' )
294
358
  end
295
359
  end
296
360
 
297
361
  describe '#run_script' do
298
362
  it 'delegates to #run_script_on with the default host' do
299
- subject.stub( :hosts ).and_return( hosts )
363
+ allow( subject ).to receive( :hosts ).and_return( hosts )
300
364
 
301
- subject.should_receive( :run_script_on ).with( master, "/tmp/test.sh", {}).once
365
+ expect( subject ).to receive( :run_script_on ).with( master, "/tmp/test.sh", {}).once
302
366
 
303
367
  subject.run_script( '/tmp/test.sh' )
304
368
  end
@@ -307,22 +371,22 @@ describe ClassMixedWithDSLHelpers do
307
371
  describe 'confine' do
308
372
  let(:logger) { double.as_null_object }
309
373
  before do
310
- subject.stub( :logger ).and_return( logger )
374
+ allow( subject ).to receive( :logger ).and_return( logger )
311
375
  end
312
376
 
313
377
  it 'skips the test if there are no applicable hosts' do
314
- subject.stub( :hosts ).and_return( [] )
315
- subject.stub( :hosts= )
316
- logger.should_receive( :warn )
317
- subject.should_receive( :skip_test ).
378
+ allow( subject ).to receive( :hosts ).and_return( [] )
379
+ allow( subject ).to receive( :hosts= )
380
+ expect( logger ).to receive( :warn )
381
+ expect( subject ).to receive( :skip_test ).
318
382
  with( 'No suitable hosts found' )
319
383
 
320
384
  subject.confine( :to, {} )
321
385
  end
322
386
 
323
387
  it 'raises when given mode is not :to or :except' do
324
- subject.stub( :hosts )
325
- subject.stub( :hosts= )
388
+ allow( subject ).to receive( :hosts )
389
+ allow( subject ).to receive( :hosts= )
326
390
 
327
391
  expect {
328
392
  subject.confine( :regardless, {:thing => 'value'} )
@@ -332,8 +396,8 @@ describe ClassMixedWithDSLHelpers do
332
396
  it 'rejects hosts that do not meet simple hash criteria' do
333
397
  hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'} ]
334
398
 
335
- subject.should_receive( :hosts ).and_return( hosts )
336
- subject.should_receive( :hosts= ).
399
+ expect( subject ).to receive( :hosts ).and_return( hosts )
400
+ expect( subject ).to receive( :hosts= ).
337
401
  with( [ {'thing' => 'foo'} ] )
338
402
 
339
403
  subject.confine :to, :thing => 'foo'
@@ -342,8 +406,8 @@ describe ClassMixedWithDSLHelpers do
342
406
  it 'rejects hosts that match a list of criteria' do
343
407
  hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'}, {'thing' => 'baz'} ]
344
408
 
345
- subject.should_receive( :hosts ).and_return( hosts )
346
- subject.should_receive( :hosts= ).
409
+ expect( subject ).to receive( :hosts ).and_return( hosts )
410
+ expect( subject ).to receive( :hosts= ).
347
411
  with( [ {'thing' => 'bar'} ] )
348
412
 
349
413
  subject.confine :except, :thing => ['foo', 'baz']
@@ -357,15 +421,15 @@ describe ClassMixedWithDSLHelpers do
357
421
  ret2 = (Struct.new('Result2', :stdout)).new('a_zone')
358
422
  hosts = [ host1, host2, host3 ]
359
423
 
360
- subject.should_receive( :hosts ).and_return( hosts )
361
- subject.should_receive( :on ).
424
+ expect( subject ).to receive( :hosts ).and_return( hosts )
425
+ expect( subject ).to receive( :on ).
362
426
  with( host1, '/sbin/zonename' ).
363
427
  and_return( ret1 )
364
- subject.should_receive( :on ).
428
+ expect( subject ).to receive( :on ).
365
429
  with( host1, '/sbin/zonename' ).
366
430
  and_return( ret2 )
367
431
 
368
- subject.should_receive( :hosts= ).with( [ host1 ] )
432
+ expect( subject ).to receive( :hosts= ).with( [ host1 ] )
369
433
 
370
434
  subject.confine :to, :platform => 'solaris' do |host|
371
435
  subject.on( host, '/sbin/zonename' ).stdout =~ /:global/
@@ -376,7 +440,7 @@ describe ClassMixedWithDSLHelpers do
376
440
  describe '#select_hosts' do
377
441
  let(:logger) { double.as_null_object }
378
442
  before do
379
- subject.stub( :logger ).and_return( logger )
443
+ allow( subject ).to receive( :logger ).and_return( logger )
380
444
  end
381
445
 
382
446
  it 'it returns an empty array if there are no applicable hosts' do
@@ -395,13 +459,15 @@ describe ClassMixedWithDSLHelpers do
395
459
  host1 = {'platform' => 'solaris1'}
396
460
  host2 = {'platform' => 'solaris2'}
397
461
  host3 = {'platform' => 'windows'}
398
- ret1 = (Struct.new('Result1', :stdout)).new(':global')
399
- ret2 = (Struct.new('Result2', :stdout)).new('a_zone')
462
+ ret1 = double('result1')
463
+ allow( ret1 ).to receive( :stdout ).and_return(':global')
464
+ ret2 = double('result2')
465
+ allow( ret2 ).to receive( :stdout ).and_return('a_zone')
400
466
  hosts = [ host1, host2, host3 ]
401
- subject.should_receive( :hosts ).and_return( hosts )
467
+ expect( subject ).to receive( :hosts ).and_return( hosts )
402
468
 
403
- subject.should_receive( :on ).with( host1, '/sbin/zonename' ).once.and_return( ret1 )
404
- subject.should_receive( :on ).with( host2, '/sbin/zonename' ).once.and_return( ret2 )
469
+ expect( subject ).to receive( :on ).with( host1, '/sbin/zonename' ).once.and_return( ret1 )
470
+ expect( subject ).to receive( :on ).with( host2, '/sbin/zonename' ).once.and_return( ret2 )
405
471
 
406
472
  selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host|
407
473
  subject.on(host, '/sbin/zonename').stdout =~ /:global/
@@ -412,13 +478,13 @@ describe ClassMixedWithDSLHelpers do
412
478
 
413
479
  describe '#apply_manifest_on' do
414
480
  it 'calls puppet' do
415
- subject.stub( :hosts ).and_return( hosts )
416
- subject.should_receive( :create_remote_file ).and_return( true )
417
- subject.should_receive( :puppet ).
481
+ allow( subject ).to receive( :hosts ).and_return( hosts )
482
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
483
+ expect( subject ).to receive( :puppet ).
418
484
  # with( 'apply', '--verbose', 'agent' ).
419
485
  and_return( 'puppet_command' )
420
486
 
421
- subject.should_receive( :on ).
487
+ expect( subject ).to receive( :on ).
422
488
  with( agent, 'puppet_command',
423
489
  :acceptable_exit_codes => [0] )
424
490
 
@@ -426,29 +492,29 @@ describe ClassMixedWithDSLHelpers do
426
492
  end
427
493
 
428
494
  it 'operates on an array of hosts' do
429
- subject.stub( :hosts ).and_return( hosts )
495
+ allow( subject ).to receive( :hosts ).and_return( hosts )
430
496
  the_hosts = [master, agent]
431
497
 
432
- subject.should_receive( :create_remote_file ).twice.and_return( true )
498
+ expect( subject ).to receive( :create_remote_file ).twice.and_return( true )
433
499
  the_hosts.each do |host|
434
- subject.should_receive( :puppet ).
500
+ expect( subject ).to receive( :puppet ).
435
501
  and_return( 'puppet_command' )
436
502
 
437
- subject.should_receive( :on ).
503
+ expect( subject ).to receive( :on ).
438
504
  with( host, 'puppet_command', :acceptable_exit_codes => [0] )
439
505
  end
440
506
 
441
507
  result = subject.apply_manifest_on( the_hosts, 'include foobar' )
442
- result.should(be_an(Array))
508
+ expect(result).to be_an(Array)
443
509
  end
444
510
 
445
511
  it 'adds acceptable exit codes with :catch_failures' do
446
- subject.stub( :hosts ).and_return( hosts )
447
- subject.should_receive( :create_remote_file ).and_return( true )
448
- subject.should_receive( :puppet ).
512
+ allow( subject ).to receive( :hosts ).and_return( hosts )
513
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
514
+ expect( subject ).to receive( :puppet ).
449
515
  and_return( 'puppet_command' )
450
516
 
451
- subject.should_receive( :on ).
517
+ expect( subject ).to receive( :on ).
452
518
  with( agent, 'puppet_command',
453
519
  :acceptable_exit_codes => [0,2] )
454
520
 
@@ -457,12 +523,12 @@ describe ClassMixedWithDSLHelpers do
457
523
  :catch_failures => true )
458
524
  end
459
525
  it 'allows acceptable exit codes through :catch_failures' do
460
- subject.stub( :hosts ).and_return( hosts )
461
- subject.should_receive( :create_remote_file ).and_return( true )
462
- subject.should_receive( :puppet ).
526
+ allow( subject ).to receive( :hosts ).and_return( hosts )
527
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
528
+ expect( subject ).to receive( :puppet ).
463
529
  and_return( 'puppet_command' )
464
530
 
465
- subject.should_receive( :on ).
531
+ expect( subject ).to receive( :on ).
466
532
  with( agent, 'puppet_command',
467
533
  :acceptable_exit_codes => [4,0,2] )
468
534
 
@@ -472,12 +538,12 @@ describe ClassMixedWithDSLHelpers do
472
538
  :catch_failures => true )
473
539
  end
474
540
  it 'enforces a 0 exit code through :catch_changes' do
475
- subject.stub( :hosts ).and_return( hosts )
476
- subject.should_receive( :create_remote_file ).and_return( true )
477
- subject.should_receive( :puppet ).
541
+ allow( subject ).to receive( :hosts ).and_return( hosts )
542
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
543
+ expect( subject ).to receive( :puppet ).
478
544
  and_return( 'puppet_command' )
479
545
 
480
- subject.should_receive( :on ).with(
546
+ expect( subject ).to receive( :on ).with(
481
547
  agent,
482
548
  'puppet_command',
483
549
  :acceptable_exit_codes => [0]
@@ -490,12 +556,12 @@ describe ClassMixedWithDSLHelpers do
490
556
  )
491
557
  end
492
558
  it 'enforces a 2 exit code through :expect_changes' do
493
- subject.stub( :hosts ).and_return( hosts )
494
- subject.should_receive( :create_remote_file ).and_return( true )
495
- subject.should_receive( :puppet ).
559
+ allow( subject ).to receive( :hosts ).and_return( hosts )
560
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
561
+ expect( subject ).to receive( :puppet ).
496
562
  and_return( 'puppet_command' )
497
563
 
498
- subject.should_receive( :on ).with(
564
+ expect( subject ).to receive( :on ).with(
499
565
  agent,
500
566
  'puppet_command',
501
567
  :acceptable_exit_codes => [2]
@@ -508,12 +574,12 @@ describe ClassMixedWithDSLHelpers do
508
574
  )
509
575
  end
510
576
  it 'enforces exit codes through :expect_failures' do
511
- subject.stub( :hosts ).and_return( hosts )
512
- subject.should_receive( :create_remote_file ).and_return( true )
513
- subject.should_receive( :puppet ).
577
+ allow( subject ).to receive( :hosts ).and_return( hosts )
578
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
579
+ expect( subject ).to receive( :puppet ).
514
580
  and_return( 'puppet_command' )
515
581
 
516
- subject.should_receive( :on ).with(
582
+ expect( subject ).to receive( :on ).with(
517
583
  agent,
518
584
  'puppet_command',
519
585
  :acceptable_exit_codes => [1,4,6]
@@ -526,7 +592,7 @@ describe ClassMixedWithDSLHelpers do
526
592
  )
527
593
  end
528
594
  it 'enforces exit codes through :expect_failures' do
529
- subject.stub( :hosts ).and_return( hosts )
595
+ allow( subject ).to receive( :hosts ).and_return( hosts )
530
596
  expect {
531
597
  subject.apply_manifest_on(
532
598
  agent,
@@ -537,12 +603,12 @@ describe ClassMixedWithDSLHelpers do
537
603
  }.to raise_error ArgumentError, /catch_failures.+expect_failures/
538
604
  end
539
605
  it 'enforces added exit codes through :expect_failures' do
540
- subject.stub( :hosts ).and_return( hosts )
541
- subject.should_receive( :create_remote_file ).and_return( true )
542
- subject.should_receive( :puppet ).
606
+ allow( subject ).to receive( :hosts ).and_return( hosts )
607
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
608
+ expect( subject ).to receive( :puppet ).
543
609
  and_return( 'puppet_command' )
544
610
 
545
- subject.should_receive( :on ).with(
611
+ expect( subject ).to receive( :on ).with(
546
612
  agent,
547
613
  'puppet_command',
548
614
  :acceptable_exit_codes => [1,2,3,4,5,6]
@@ -557,17 +623,17 @@ describe ClassMixedWithDSLHelpers do
557
623
  end
558
624
 
559
625
  it 'can set the --parser future flag' do
560
- subject.stub( :hosts ).and_return( hosts )
561
- subject.should_receive( :create_remote_file ).and_return( true )
626
+ allow( subject ).to receive( :hosts ).and_return( hosts )
627
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
562
628
 
563
- expect( subject ).to receive( :on ).with {|h, command, opts|
629
+ expect( subject ).to receive( :on ) do |h, command, opts|
564
630
  cmdline = command.cmd_line( h )
565
631
  expect( h ).to be == agent
566
632
  expect( cmdline ).to include('puppet apply')
567
633
  expect( cmdline ).to include('--parser=future')
568
634
  expect( cmdline ).to include('--detailed-exitcodes')
569
635
  expect( cmdline ).to include('--verbose')
570
- }
636
+ end
571
637
 
572
638
  subject.apply_manifest_on(
573
639
  agent,
@@ -579,16 +645,16 @@ describe ClassMixedWithDSLHelpers do
579
645
  end
580
646
 
581
647
  it 'can set the --noops flag' do
582
- subject.stub( :hosts ).and_return( hosts )
583
- subject.should_receive( :create_remote_file ).and_return( true )
584
- expect( subject ).to receive( :on ).with {|h, command, opts|
648
+ allow( subject ).to receive( :hosts ).and_return( hosts )
649
+ expect( subject ).to receive( :create_remote_file ).and_return( true )
650
+ expect( subject ).to receive( :on ) do |h, command, opts|
585
651
  cmdline = command.cmd_line( h )
586
652
  expect( h ).to be == agent
587
653
  expect( cmdline ).to include('puppet apply')
588
654
  expect( cmdline ).to include('--detailed-exitcodes')
589
655
  expect( cmdline ).to include('--verbose')
590
656
  expect( cmdline ).to include('--noop')
591
- }
657
+ end
592
658
  subject.apply_manifest_on(
593
659
  agent,
594
660
  'class { "boo": }',
@@ -599,11 +665,28 @@ describe ClassMixedWithDSLHelpers do
599
665
  end
600
666
  end
601
667
 
668
+ it 'can set the --debug flag' do
669
+ allow( subject ).to receive( :hosts ).and_return( hosts )
670
+ allow( subject ).to receive( :create_remote_file ).and_return( true )
671
+ expect( subject ).to receive( :on ) do |h, command, opts|
672
+ cmdline = command.cmd_line( h )
673
+ expect( h ).to be == agent
674
+ expect( cmdline ).to include('puppet apply')
675
+ expect( cmdline ).not_to include('--verbose')
676
+ expect( cmdline ).to include('--debug')
677
+ end
678
+ subject.apply_manifest_on(
679
+ agent,
680
+ 'class { "boo": }',
681
+ :debug => true,
682
+ )
683
+ end
684
+
602
685
  describe "#apply_manifest" do
603
686
  it "delegates to #apply_manifest_on with the default host" do
604
- subject.stub( :hosts ).and_return( hosts )
687
+ allow( subject ).to receive( :hosts ).and_return( hosts )
605
688
 
606
- subject.should_receive( :apply_manifest_on ).with( master, 'manifest', {:opt => 'value'}).once
689
+ expect( subject ).to receive( :apply_manifest_on ).with( master, 'manifest', {:opt => 'value'}).once
607
690
 
608
691
  subject.apply_manifest( 'manifest', {:opt => 'value'} )
609
692
 
@@ -612,17 +695,17 @@ describe ClassMixedWithDSLHelpers do
612
695
 
613
696
  describe '#stub_hosts_on' do
614
697
  it 'executes puppet on the host passed and ensures it is reverted' do
615
- subject.stub( :hosts ).and_return( hosts )
698
+ allow( subject ).to receive( :hosts ).and_return( hosts )
616
699
  logger = double.as_null_object
617
700
 
618
- subject.stub( :logger ).and_return( logger )
619
- subject.should_receive( :on ).twice
620
- subject.should_receive( :teardown ).and_yield
621
- subject.should_receive( :puppet ).once.
701
+ allow( subject ).to receive( :logger ).and_return( logger )
702
+ expect( subject ).to receive( :on ).twice
703
+ expect( subject ).to receive( :teardown ).and_yield
704
+ expect( subject ).to receive( :puppet ).once.
622
705
  with( 'resource', 'host',
623
706
  'puppetlabs.com',
624
707
  'ensure=present', 'ip=127.0.0.1' )
625
- subject.should_receive( :puppet ).once.
708
+ expect( subject ).to receive( :puppet ).once.
626
709
  with( 'resource', 'host',
627
710
  'puppetlabs.com',
628
711
  'ensure=absent' )
@@ -632,10 +715,10 @@ describe ClassMixedWithDSLHelpers do
632
715
  end
633
716
 
634
717
  describe "#stub_hosts" do
635
- it "delegates to #stub_hosts_on with the default host" do
636
- subject.stub( :hosts ).and_return( hosts )
718
+ it "delegates to stub_hosts_on with the default host" do
719
+ allow( subject ).to receive( :hosts ).and_return( hosts )
637
720
 
638
- subject.should_receive( :stub_hosts_on ).with( master, 'ipspec' ).once
721
+ expect( subject ).to receive( :stub_hosts_on ).with( master, 'ipspec' ).once
639
722
 
640
723
  subject.stub_hosts( 'ipspec' )
641
724
 
@@ -644,13 +727,13 @@ describe ClassMixedWithDSLHelpers do
644
727
 
645
728
  describe '#stub_forge_on' do
646
729
  it 'stubs forge.puppetlabs.com with the value of `forge`' do
647
- subject.stub( :hosts ).and_return( hosts )
730
+ allow( subject ).to receive( :hosts ).and_return( hosts )
648
731
  host = make_host('my_host', {})
649
- Resolv.should_receive( :getaddress ).
732
+ expect( Resolv ).to receive( :getaddress ).
650
733
  with( 'my_forge.example.com' ).and_return( '127.0.0.1' )
651
- subject.should_receive( :stub_hosts_on ).
734
+ expect( subject ).to receive( :stub_hosts_on ).
652
735
  with( host, 'forge.puppetlabs.com' => '127.0.0.1' )
653
- subject.should_receive( :stub_hosts_on ).
736
+ expect( subject ).to receive( :stub_hosts_on ).
654
737
  with( host, 'forgeapi.puppetlabs.com' => '127.0.0.1' )
655
738
 
656
739
  subject.stub_forge_on( host, 'my_forge.example.com' )
@@ -658,11 +741,11 @@ describe ClassMixedWithDSLHelpers do
658
741
  end
659
742
 
660
743
  describe "#stub_forge" do
661
- it "delegates to #stub_forge_on with the default host" do
662
- subject.stub( :options ).and_return( {} )
663
- subject.stub( :hosts ).and_return( hosts )
744
+ it "delegates to stub_forge_on with the default host" do
745
+ allow( subject ).to receive( :options ).and_return( {} )
746
+ allow( subject ).to receive( :hosts ).and_return( hosts )
664
747
 
665
- subject.should_receive( :stub_forge_on ).with( master, nil ).once
748
+ expect( subject ).to receive( :stub_forge_on ).with( master, nil ).once
666
749
 
667
750
  subject.stub_forge( )
668
751
 
@@ -700,7 +783,7 @@ describe ClassMixedWithDSLHelpers do
700
783
  let( :result_fail ) { Beaker::Result.new( [], "" ) }
701
784
  let( :result_pass ) { Beaker::Result.new( [], "" ) }
702
785
  before :each do
703
- subject.stub( :sleep ).and_return( true )
786
+ allow( subject ).to receive( :sleep ).and_return( true )
704
787
  result_fail.stdout = 'stdout'
705
788
  result_fail.stderr = 'stderr'
706
789
  result_fail.exit_code = 1
@@ -712,13 +795,13 @@ describe ClassMixedWithDSLHelpers do
712
795
  it 'runs the pe-puppet on a system without pe-puppet-agent' do
713
796
  vardir = '/var'
714
797
  deb_agent = make_host( 'deb', :platform => 'debian-7-amd64' )
715
- deb_agent.stub( :puppet ).and_return( { 'vardir' => vardir } )
798
+ allow( deb_agent ).to receive( :puppet ).and_return( { 'vardir' => vardir } )
716
799
 
717
- subject.stub( :hosts ).and_return( hosts )
718
- subject.should_receive( :on ).with( deb_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
719
- subject.should_receive( :on ).with( deb_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
720
- subject.should_receive( :puppet_resource ).with( "service", "pe-puppet", "ensure=stopped").once
721
- subject.should_receive( :on ).once
800
+ allow( subject ).to receive( :hosts ).and_return( hosts )
801
+ expect( subject ).to receive( :on ).with( deb_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
802
+ expect( subject ).to receive( :on ).with( deb_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
803
+ expect( subject ).to receive( :puppet_resource ).with( "service", "pe-puppet", "ensure=stopped").once
804
+ expect( subject ).to receive( :on ).once
722
805
 
723
806
  subject.stop_agent_on( deb_agent )
724
807
 
@@ -727,13 +810,13 @@ describe ClassMixedWithDSLHelpers do
727
810
  it 'runs the pe-puppet-agent on a unix system with pe-puppet-agent' do
728
811
  vardir = '/var'
729
812
  el_agent = make_host( 'el', :platform => 'el-5-x86_64' )
730
- el_agent.stub( :puppet ).and_return( { 'vardir' => vardir } )
813
+ allow( el_agent ).to receive( :puppet ).and_return( { 'vardir' => vardir } )
731
814
 
732
- subject.stub( :hosts ).and_return( hosts )
733
- subject.should_receive( :on ).with( el_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
734
- subject.should_receive( :on ).with( el_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_pass )
735
- subject.should_receive( :puppet_resource ).with("service", "pe-puppet-agent", "ensure=stopped").once
736
- subject.should_receive( :on ).once
815
+ allow( subject ).to receive( :hosts ).and_return( hosts )
816
+ expect( subject ).to receive( :on ).with( el_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail )
817
+ expect( subject ).to receive( :on ).with( el_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_pass )
818
+ expect( subject ).to receive( :puppet_resource ).with("service", "pe-puppet-agent", "ensure=stopped").once
819
+ expect( subject ).to receive( :on ).once
737
820
 
738
821
  subject.stop_agent_on( el_agent )
739
822
  end
@@ -742,9 +825,9 @@ describe ClassMixedWithDSLHelpers do
742
825
 
743
826
  describe "#stop_agent" do
744
827
  it 'delegates to #stop_agent_on with default host' do
745
- subject.stub( :hosts ).and_return( hosts )
828
+ allow( subject ).to receive( :hosts ).and_return( hosts )
746
829
 
747
- subject.should_receive( :stop_agent_on ).with( master ).once
830
+ expect( subject ).to receive( :stop_agent_on ).with( master ).once
748
831
 
749
832
  subject.stop_agent( )
750
833
 
@@ -753,35 +836,34 @@ describe ClassMixedWithDSLHelpers do
753
836
 
754
837
  describe "#sign_certificate_for" do
755
838
  it 'signs certs' do
756
- subject.stub( :sleep ).and_return( true )
839
+ allow( subject ).to receive( :sleep ).and_return( true )
757
840
 
758
841
  result.stdout = "+ \"#{agent}\""
759
- subject.stub( :hosts ).and_return( hosts )
842
+ allow( subject ).to receive( :hosts ).and_return( hosts )
760
843
 
761
- subject.stub( :puppet ) do |arg|
844
+ allow( subject ).to receive( :puppet ) do |arg|
762
845
  arg
763
846
  end
764
847
 
765
- subject.should_receive( :on ).with( master, "cert --sign --all", :acceptable_exit_codes => [0,24]).once
766
- subject.should_receive( :on ).with( master, "cert --list --all").once.and_return( result )
767
-
848
+ expect( subject ).to receive( :on ).with( master, "cert --sign --all --allow-dns-alt-names", :acceptable_exit_codes => [0,24]).once
849
+ expect( subject ).to receive( :on ).with( master, "cert --list --all").once.and_return( result )
768
850
 
769
851
  subject.sign_certificate_for( agent )
770
852
  end
771
853
 
772
854
  it 'retries 11 times before quitting' do
773
- subject.stub( :sleep ).and_return( true )
855
+ allow( subject ).to receive( :sleep ).and_return( true )
774
856
 
775
857
  result.stdout = " \"#{agent}\""
776
- subject.stub( :hosts ).and_return( hosts )
858
+ allow( subject ).to receive( :hosts ).and_return( hosts )
777
859
 
778
- subject.stub( :puppet ) do |arg|
860
+ allow( subject ).to receive( :puppet ) do |arg|
779
861
  arg
780
862
  end
781
863
 
782
- subject.should_receive( :on ).with( master, "cert --sign --all", :acceptable_exit_codes => [0,24]).exactly( 11 ).times
783
- subject.should_receive( :on ).with( master, "cert --list --all").exactly( 11 ).times.and_return( result )
784
- subject.should_receive( :fail_test ).once
864
+ expect( subject ).to receive( :on ).with( master, "cert --sign --all --allow-dns-alt-names", :acceptable_exit_codes => [0,24]).exactly( 11 ).times
865
+ expect( subject ).to receive( :on ).with( master, "cert --list --all").exactly( 11 ).times.and_return( result )
866
+ expect( subject ).to receive( :fail_test ).once
785
867
 
786
868
  subject.sign_certificate_for( agent )
787
869
  end
@@ -790,9 +872,9 @@ describe ClassMixedWithDSLHelpers do
790
872
 
791
873
  describe "#sign_certificate" do
792
874
  it 'delegates to #sign_certificate_for with the default host' do
793
- subject.stub( :hosts ).and_return( hosts )
875
+ allow( subject ).to receive( :hosts ).and_return( hosts )
794
876
 
795
- subject.should_receive( :sign_certificate_for ).with( master ).once
877
+ expect( subject ).to receive( :sign_certificate_for ).with( master ).once
796
878
 
797
879
  subject.sign_certificate( )
798
880
  end
@@ -813,14 +895,14 @@ describe ClassMixedWithDSLHelpers do
813
895
 
814
896
  def stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created
815
897
  subject.instance_variable_set(:@path, test_case_path)
816
- host.stub(:tmpdir).and_return(tmpdir_path)
817
- host.stub(:file_exist?).and_return(true)
818
- subject.stub( :options ).and_return( {} )
898
+ allow( host ).to receive(:tmpdir).and_return(tmpdir_path)
899
+ allow( host ).to receive(:file_exist?).and_return(true)
900
+ allow( subject ).to receive( :options ).and_return( {} )
819
901
  end
820
902
 
821
903
  before do
822
904
  stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created
823
- subject.stub(:curl_with_retries)
905
+ allow( subject ).to receive(:curl_with_retries)
824
906
  end
825
907
 
826
908
  it "raises an ArgumentError if you try to submit a String instead of a Hash of options" do
@@ -828,7 +910,7 @@ describe ClassMixedWithDSLHelpers do
828
910
  end
829
911
 
830
912
  it 'raises the early_exception if backup_the_file fails' do
831
- subject.should_receive(:backup_the_file).and_raise(RuntimeError.new('puppet conf backup failed'))
913
+ expect( subject ).to receive(:backup_the_file).and_raise(RuntimeError.new('puppet conf backup failed'))
832
914
  expect {
833
915
  subject.with_puppet_running_on(host, {})
834
916
  }.to raise_error(RuntimeError, /puppet conf backup failed/)
@@ -859,30 +941,30 @@ describe ClassMixedWithDSLHelpers do
859
941
  let(:logger) { double }
860
942
 
861
943
  def stub_post_setup
862
- subject.stub( :restore_puppet_conf_from_backup)
863
- subject.stub( :bounce_service)
864
- subject.stub( :stop_puppet_from_source_on)
865
- subject.stub( :dump_puppet_log)
866
- subject.stub( :restore_puppet_conf_from_backup)
867
- subject.stub( :puppet_master_started)
868
- subject.stub( :start_puppet_from_source_on!)
869
- subject.stub( :lay_down_new_puppet_conf)
870
- subject.stub( :logger) .and_return( logger )
871
- logger.stub( :error)
872
- logger.stub( :debug)
944
+ allow( subject ).to receive( :restore_puppet_conf_from_backup)
945
+ allow( subject ).to receive( :bounce_service)
946
+ allow( subject ).to receive( :stop_puppet_from_source_on)
947
+ allow( subject ).to receive( :dump_puppet_log)
948
+ allow( subject ).to receive( :restore_puppet_conf_from_backup)
949
+ allow( subject ).to receive( :puppet_master_started)
950
+ allow( subject ).to receive( :start_puppet_from_source_on!)
951
+ allow( subject ).to receive( :lay_down_new_puppet_conf)
952
+ allow( subject ).to receive( :logger) .and_return( logger )
953
+ allow( logger ).to receive( :error)
954
+ allow( logger ).to receive( :debug)
873
955
  end
874
956
 
875
957
  before do
876
958
  stub_post_setup
877
- subject.stub( :options) .and_return( {:is_puppetserver => true})
878
- subject.stub( :modify_tk_config)
879
- host.stub(:puppet).with('master') .and_return({'confdir' => default_confdir,
959
+ allow( subject ).to receive( :options) .and_return( {:is_puppetserver => true})
960
+ allow( subject ).to receive( :modify_tk_config)
961
+ allow( host ).to receive(:puppet).with('master') .and_return({'confdir' => default_confdir,
880
962
  'vardir' => default_vardir})
881
963
  end
882
964
 
883
965
  describe 'and command line args passed' do
884
966
  it 'modifies SUT trapperkeeper configuration w/ command line args' do
885
- subject.should_receive( :modify_tk_config).with(host, puppetserver_conf,
967
+ expect( subject ).to receive( :modify_tk_config).with(host, puppetserver_conf,
886
968
  custom_puppetserver_opts)
887
969
  subject.with_puppet_running_on(host, conf_opts)
888
970
  end
@@ -891,7 +973,7 @@ describe ClassMixedWithDSLHelpers do
891
973
  describe 'and no command line args passed' do
892
974
  let(:command_line_args) { nil }
893
975
  it 'modifies SUT trapperkeeper configuration w/ puppet defaults' do
894
- subject.should_receive( :modify_tk_config).with(host, puppetserver_conf,
976
+ expect( subject ).to receive( :modify_tk_config).with(host, puppetserver_conf,
895
977
  default_puppetserver_opts)
896
978
  subject.with_puppet_running_on(host, conf_opts)
897
979
  end
@@ -900,7 +982,7 @@ describe ClassMixedWithDSLHelpers do
900
982
 
901
983
  describe "with valid arguments" do
902
984
  before do
903
- Tempfile.should_receive(:open).with('beaker')
985
+ expect( Tempfile ).to receive(:open).with('beaker')
904
986
  end
905
987
 
906
988
  context 'for pe hosts' do
@@ -915,7 +997,7 @@ describe ClassMixedWithDSLHelpers do
915
997
 
916
998
  it 'yields to a block after bouncing service' do
917
999
  execution = 0
918
- subject.stub(:curl_with_retries)
1000
+ allow( subject ).to receive(:curl_with_retries)
919
1001
  expect do
920
1002
  subject.with_puppet_running_on(host, {}) do
921
1003
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(1).times
@@ -934,14 +1016,14 @@ describe ClassMixedWithDSLHelpers do
934
1016
  end
935
1017
 
936
1018
  it 'bounces puppet twice' do
937
- subject.stub(:curl_with_retries)
1019
+ allow( subject ).to receive(:curl_with_retries)
938
1020
  subject.with_puppet_running_on(host, {})
939
1021
  expect(host).to execute_commands_matching(/apache2ctl graceful/).exactly(2).times
940
1022
  end
941
1023
 
942
1024
  it 'yields to a block after bouncing service' do
943
1025
  execution = 0
944
- subject.stub(:curl_with_retries)
1026
+ allow( subject ).to receive(:curl_with_retries)
945
1027
  expect do
946
1028
  subject.with_puppet_running_on(host, {}) do
947
1029
  expect(host).to execute_commands_matching(/apache2ctl graceful/).once
@@ -956,7 +1038,7 @@ describe ClassMixedWithDSLHelpers do
956
1038
  let(:use_service) { true }
957
1039
 
958
1040
  it 'stops and starts master using service scripts' do
959
- subject.stub(:curl_with_retries)
1041
+ allow( subject ).to receive(:curl_with_retries)
960
1042
  subject.with_puppet_running_on(host, {})
961
1043
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times
962
1044
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
@@ -980,15 +1062,15 @@ describe ClassMixedWithDSLHelpers do
980
1062
  let('use-service') { false }
981
1063
 
982
1064
  it 'does not try to stop if not started' do
983
- subject.should_receive(:start_puppet_from_source_on!).and_return false
984
- subject.should_not_receive(:stop_puppet_from_source_on)
1065
+ expect( subject ).to receive(:start_puppet_from_source_on!).and_return false
1066
+ expect( subject ).to_not receive(:stop_puppet_from_source_on)
985
1067
 
986
1068
  subject.with_puppet_running_on(host, {})
987
1069
  end
988
1070
 
989
1071
  context 'successfully' do
990
1072
  before do
991
- host.should_receive(:port_open?).with(8140).and_return(true)
1073
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
992
1074
  end
993
1075
 
994
1076
  it 'starts puppet from source' do
@@ -1044,7 +1126,7 @@ describe ClassMixedWithDSLHelpers do
1044
1126
 
1045
1127
  context 'when a puppetservice is not used' do
1046
1128
  before do
1047
- host.should_receive(:port_open?).with(8140).and_return(true)
1129
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
1048
1130
  end
1049
1131
 
1050
1132
  it 'backs up puppet.conf' do
@@ -1060,7 +1142,7 @@ describe ClassMixedWithDSLHelpers do
1060
1142
  end
1061
1143
 
1062
1144
  it "doesn't restore a non-existent file" do
1063
- subject.stub(:backup_the_file)
1145
+ allow( subject ).to receive(:backup_the_file)
1064
1146
  subject.with_puppet_running_on(host, {})
1065
1147
  expect(host).to execute_commands_matching(/rm -f '#{original_location}'/)
1066
1148
  end
@@ -1068,14 +1150,17 @@ describe ClassMixedWithDSLHelpers do
1068
1150
  end
1069
1151
 
1070
1152
  describe 'handling failures' do
1153
+
1154
+ let(:logger) { double.as_null_object }
1071
1155
  before do
1072
- subject.should_receive(:stop_puppet_from_source_on).and_raise(RuntimeError.new('Also failed in teardown.'))
1156
+ allow( subject ).to receive( :logger ).and_return( logger )
1157
+ expect( subject ).to receive(:stop_puppet_from_source_on).and_raise(RuntimeError.new('Also failed in teardown.'))
1073
1158
  end
1074
1159
 
1075
1160
  it 'does not swallow an exception raised from within test block if ensure block also fails' do
1076
- host.should_receive(:port_open?).with(8140).and_return(true)
1161
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
1077
1162
 
1078
- subject.logger.should_receive(:error).with(/Raised during attempt to teardown.*Also failed in teardown/)
1163
+ expect( subject.logger ).to receive(:error).with(/Raised during attempt to teardown.*Also failed in teardown/)
1079
1164
 
1080
1165
  expect do
1081
1166
  subject.with_puppet_running_on(host, {}) { raise 'Failed while yielding.' }
@@ -1083,9 +1168,9 @@ describe ClassMixedWithDSLHelpers do
1083
1168
  end
1084
1169
 
1085
1170
  it 'dumps the puppet logs if there is an error in the teardown' do
1086
- host.should_receive(:port_open?).with(8140).and_return(true)
1171
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
1087
1172
 
1088
- subject.logger.should_receive(:notify).with(/Dumping master log/)
1173
+ expect( subject.logger ).to receive(:notify).with(/Dumping master log/)
1089
1174
 
1090
1175
  expect do
1091
1176
  subject.with_puppet_running_on(host, {})
@@ -1093,9 +1178,9 @@ describe ClassMixedWithDSLHelpers do
1093
1178
  end
1094
1179
 
1095
1180
  it 'does not mask the teardown error with an error from dumping the logs' do
1096
- host.should_receive(:port_open?).with(8140).and_return(true)
1181
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
1097
1182
 
1098
- subject.logger.should_receive(:notify).with(/Dumping master log/).and_raise("Error from dumping logs")
1183
+ expect( subject.logger ).to receive(:notify).with(/Dumping master log/).and_raise("Error from dumping logs")
1099
1184
 
1100
1185
  expect do
1101
1186
  subject.with_puppet_running_on(host, {})
@@ -1103,8 +1188,8 @@ describe ClassMixedWithDSLHelpers do
1103
1188
  end
1104
1189
 
1105
1190
  it 'does not swallow a teardown exception if no earlier exception was raised' do
1106
- host.should_receive(:port_open?).with(8140).and_return(true)
1107
- subject.logger.should_not_receive(:error)
1191
+ expect( host ).to receive(:port_open?).with(8140).and_return(true)
1192
+ expect( subject.logger).to_not receive(:error)
1108
1193
  expect do
1109
1194
  subject.with_puppet_running_on(host, {})
1110
1195
  end.to raise_error(RuntimeError, 'Also failed in teardown.')
@@ -1115,9 +1200,9 @@ describe ClassMixedWithDSLHelpers do
1115
1200
 
1116
1201
  describe '#with_puppet_running' do
1117
1202
  it 'delegates to #with_puppet_running_on with the default host' do
1118
- subject.stub( :hosts ).and_return( hosts )
1203
+ allow( subject ).to receive( :hosts ).and_return( hosts )
1119
1204
 
1120
- subject.should_receive( :with_puppet_running_on ).with( master, {:opt => 'value'}, '/dir').once
1205
+ expect( subject ).to receive( :with_puppet_running_on ).with( master, {:opt => 'value'}, '/dir').once
1121
1206
 
1122
1207
  subject.with_puppet_running( {:opt => 'value'}, '/dir' )
1123
1208
 
@@ -1128,18 +1213,18 @@ describe ClassMixedWithDSLHelpers do
1128
1213
  describe '#fact_on' do
1129
1214
  it 'retrieves a fact on a single host' do
1130
1215
  result.stdout = "family\n"
1131
- subject.should_receive(:facter).with('osfamily',{}).once
1132
- subject.should_receive(:on).and_return(result)
1216
+ expect( subject ).to receive(:facter).with('osfamily',{}).once
1217
+ expect( subject ).to receive(:on).and_return(result)
1133
1218
 
1134
1219
  expect( subject.fact_on('host','osfamily') ).to be === result.stdout.chomp
1135
1220
  end
1136
1221
 
1137
1222
  it 'retrieves an array of facts from multiple hosts' do
1138
- subject.stub( :hosts ).and_return( hosts )
1223
+ allow( subject ).to receive( :hosts ).and_return( hosts )
1139
1224
  times = hosts.length
1140
1225
  result.stdout = "family\n"
1141
1226
  hosts.each do |host|
1142
- host.should_receive(:exec).and_return(result)
1227
+ expect( host ).to receive(:exec).and_return(result)
1143
1228
  end
1144
1229
 
1145
1230
  expect( subject.fact_on(hosts,'osfamily') ).to be === [result.stdout.chomp] * hosts.length
@@ -1149,8 +1234,8 @@ describe ClassMixedWithDSLHelpers do
1149
1234
 
1150
1235
  describe '#fact' do
1151
1236
  it 'delegates to #fact_on with the default host' do
1152
- subject.stub(:hosts).and_return(hosts)
1153
- subject.should_receive(:fact_on).with(master,"osfamily",{}).once
1237
+ allow( subject ).to receive(:hosts).and_return(hosts)
1238
+ expect( subject ).to receive(:fact_on).with(master,"osfamily",{}).once
1154
1239
 
1155
1240
  subject.fact('osfamily')
1156
1241
  end
@@ -1165,15 +1250,15 @@ describe ClassMixedWithDSLHelpers do
1165
1250
 
1166
1251
  shared_examples 'modify-tk-config-without-error' do
1167
1252
  it 'dumps to the SUT config file path' do
1168
- JSON.stub(:dump)
1169
- subject.stub(:create_remote_file).with(host, config_file_path, anything())
1253
+ allow( JSON ).to receive(:dump)
1254
+ allow( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
1170
1255
  subject.modify_tk_config(host, config_file_path, options_hash, replace)
1171
1256
  end
1172
1257
  end
1173
1258
 
1174
1259
  before do
1175
- host.stub(:file_exist?).with(invalid_config_file_path).and_return(false)
1176
- host.stub(:file_exist?).with(config_file_path).and_return(true)
1260
+ allow( host ).to receive(:file_exist?).with(invalid_config_file_path).and_return(false)
1261
+ allow( host ).to receive(:file_exist?).with(config_file_path).and_return(true)
1177
1262
  end
1178
1263
 
1179
1264
  describe 'if file does not exist on SUT' do
@@ -1195,15 +1280,15 @@ describe ClassMixedWithDSLHelpers do
1195
1280
  describe 'given a false value to its `replace` parameter' do
1196
1281
  let(:replace) { false }
1197
1282
  before do
1198
- subject.should_receive(:read_tk_config_string).with(anything())
1283
+ expect( subject ).to receive(:read_tk_config_string).with(anything())
1199
1284
  end
1200
1285
  include_examples('modify-tk-config-without-error')
1201
1286
  end
1202
1287
 
1203
1288
  describe 'given a true value to its `replace` parameter' do
1204
1289
  before do
1205
- JSON.should_receive(:dump)
1206
- subject.should_receive(:create_remote_file).with(host, config_file_path, anything())
1290
+ expect( JSON ).to receive(:dump)
1291
+ expect( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
1207
1292
  end
1208
1293
  include_examples('modify-tk-config-without-error')
1209
1294
  end