File tree 3 files changed +6
-36
lines changed
3 files changed +6
-36
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ def stop
19
19
before do
20
20
@agent = Puppet ::Agent . new ( AgentTestClient , false )
21
21
22
- # make Puppet::Application safe for stubbing; restore in an :after block; silence warnings for this.
23
- with_verbose_disabled { Puppet ::Application = Class . new ( Puppet ::Application ) }
22
+ # make Puppet::Application safe for stubbing
23
+ stub_const ( ' Puppet::Application' , Class . new ( Puppet ::Application ) )
24
24
allow ( Puppet ::Application ) . to receive ( :clear? ) . and_return ( true )
25
25
Puppet ::Application . class_eval do
26
26
class << self
@@ -35,11 +35,6 @@ def controlled_run(&block)
35
35
allow ( Puppet ::SSL ::StateMachine ) . to receive ( :new ) . and_return ( machine )
36
36
end
37
37
38
- after do
39
- # restore Puppet::Application from stub-safe subclass, and silence warnings
40
- with_verbose_disabled { Puppet ::Application = Puppet ::Application . superclass }
41
- end
42
-
43
38
it "should set its client class at initialization" do
44
39
expect ( Puppet ::Agent . new ( "foo" , false ) . client_class ) . to eq ( "foo" )
45
40
end
Original file line number Diff line number Diff line change 3
3
require 'puppet/agent'
4
4
require 'puppet/configurer'
5
5
6
- def without_warnings
7
- flag = $VERBOSE
8
- $VERBOSE = nil
9
- yield
10
- $VERBOSE = flag
11
- end
12
-
13
6
describe Puppet ::Daemon , :unless => Puppet ::Util ::Platform . windows? do
14
7
include PuppetSpec ::Files
15
8
@@ -91,14 +84,8 @@ def run_loop(jobs)
91
84
describe "when stopping" do
92
85
before do
93
86
allow ( Puppet ::Util ::Log ) . to receive ( :close_all )
94
- # to make the global safe to mock, set it to a subclass of itself,
95
- # then restore it in an after pass
96
- without_warnings { Puppet ::Application = Class . new ( Puppet ::Application ) }
97
- end
98
-
99
- after do
100
- # restore from the superclass so we lose the stub garbage
101
- without_warnings { Puppet ::Application = Puppet ::Application . superclass }
87
+ # to make the global safe to mock, set it to a subclass of itself
88
+ stub_const ( 'Puppet::Application' , Class . new ( Puppet ::Application ) )
102
89
end
103
90
104
91
it 'should request a stop from Puppet::Application' do
@@ -143,11 +130,7 @@ def run_loop(jobs)
143
130
144
131
describe "when restarting" do
145
132
before do
146
- without_warnings { Puppet ::Application = Class . new ( Puppet ::Application ) }
147
- end
148
-
149
- after do
150
- without_warnings { Puppet ::Application = Puppet ::Application . superclass }
133
+ stub_const ( 'Puppet::Application' , Class . new ( Puppet ::Application ) )
151
134
end
152
135
153
136
it 'should set Puppet::Application.restart!' do
Original file line number Diff line number Diff line change @@ -266,15 +266,7 @@ def exec_stub(options = {})
266
266
267
267
describe "on platforms where path separator is not :" do
268
268
before :each do
269
- @old_verbosity = $VERBOSE
270
- $VERBOSE = nil
271
- @old_separator = File ::PATH_SEPARATOR
272
- File ::PATH_SEPARATOR = 'q'
273
- end
274
-
275
- after :each do
276
- File ::PATH_SEPARATOR = @old_separator
277
- $VERBOSE = @old_verbosity
269
+ stub_const ( 'File::PATH_SEPARATOR' , 'q' )
278
270
end
279
271
280
272
it "should use the path separator of the current platform" do
You can’t perform that action at this time.
0 commit comments