getsentry / getsentry/sentry-ruby

`teardown_sentry_test` clears global event processors

Offen
#2,466 3 Kommentare 0 Reaktionen 1 zugewiesene Person Zugewiesen an @st0012 Auf GitHub ansehen
Question Ruby Tests
Vorherrschende Sprache
Ruby
Sterne
987
Forks
541
Ø Merge
17 Std. 40 Min.
Gemergte PRs (30 T.)
19

Beschreibung

### Issue Description

The test teardown method `teardown_sentry_test` clears the global event processors `Sentry::Scope.global_event_processors`. Any application global event processors are wiped after one test.

Reasoning:
1. The global event processors are by nature global and any setup by the application are cleared. This makes the test setup and teardown process uneven: what is setup before the test is not retained after the teardown of the test.
2. This method is suggested to be run after every example/test, so this teardown behavior would necessitate running the application setup before every test in order to setup any global event processors.

This behavior was introduced in #2342.

### Reproduction Steps

```ruby
require "sentry/test_helper"

RSpec.configure do |config|
config.include Sentry::TestHelper
end

RSpec.describe "#teardown_sentry_test" do
before do
Sentry.add_global_event_processor { |event| event }
end

it do
expect { teardown_sentry_test }.not_to change(Sentry::Scope, :global_event_processors)
end
end
```

### Expected Behavior

The list of global events processors `Sentry::Scope.global_event_processors` is retained.

### Actual Behavior

The list of global events processors `Sentry::Scope.global_event_processors` is cleared.

### Ruby Version

3.3.5

### SDK Version

5.21.0

### Integration and Its Version

Rails 7.1.4

### Sentry Config

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.