From ac7718ebc3140d2990841fc68ad2ccc7cac66fbf Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Wed, 28 Oct 2026 21:26:16 +0100 Subject: [PATCH] test(vernier): Cleanup stop_profile properly --- sentry-ruby/spec/sentry/vernier/profiler_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sentry-ruby/spec/sentry/vernier/profiler_spec.rb b/sentry-ruby/spec/sentry/vernier/profiler_spec.rb index af373a660..c7b3d501f 100644 --- a/sentry-ruby/spec/sentry/vernier/profiler_spec.rb +++ b/sentry-ruby/spec/sentry/vernier/profiler_spec.rb @@ -16,6 +16,10 @@ end end + after do + Vernier.stop_profile if Vernier.instance_variable_get(:@collector) + end + let(:profiles_sample_rate) { 1.0 } let(:traces_sample_rate) { 1.0 } @@ -147,7 +151,7 @@ it 'stops Vernier if sampled and started' do profiler.set_initial_sample_decision(true) profiler.start - expect(Vernier).to receive(:stop_profile) + expect(Vernier).to receive(:stop_profile).and_call_original profiler.stop end @@ -161,7 +165,10 @@ it 'does not crash when stopping Vernier crashed' do profiler.set_initial_sample_decision(true) profiler.start - expect(Vernier).to receive(:stop_profile).and_raise(RuntimeError.new("Profile not started")) + expect(Vernier).to receive(:stop_profile).and_wrap_original do |stop_profile| + stop_profile.call + raise RuntimeError.new("Profile not started") + end profiler.stop end end