Skip to content

Commit b227eee

Browse files
authored
Fix test leak of global Steno state (#4564)
I noticed some tests flaking when using the `tail_logs` test helper. The cause appeared to be an extra `"worker_name"=>"test_worker"` included in the log data, which was breaking the `hash_including` matcher.
1 parent 178065c commit b227eee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spec/unit/lib/delayed_job/delayed_worker_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@
8989
describe '#start_working' do
9090
let(:cc_delayed_worker) { CloudController::DelayedWorker.new(options) }
9191

92-
before { allow(delayed_worker).to receive(:name).and_return(options[:name]) }
92+
before do
93+
@steno_config_backup = Steno.config
94+
allow(delayed_worker).to receive(:name).and_return(options[:name])
95+
end
96+
97+
after do
98+
Steno.init(@steno_config_backup)
99+
end
93100

94101
it 'sets up the environment and starts the worker' do
95102
expect(environment).to receive(:setup_environment).with(nil)

0 commit comments

Comments
 (0)