Skip to content

Commit e4b8026

Browse files
committed
Move steno tests to isolated_specs to prevent mock leakage
The Steno::Sink::Syslog singleton was causing sporadic test failures when steno tests ran in parallel with other CCNG tests. RSpec doubles stored in the singleton would leak into other tests, causing "double leaked into another example" errors. Instead of adding workarounds to spec_helper.rb, isolate the steno tests by moving them to spec/isolated_specs/steno/. This follows the existing pattern for tests that affect global state. Changes: - Move spec/unit/lib/steno/ to spec/isolated_specs/steno/ - Update steno spec_helper to call reset! and close Syslog after tests - Remove global syslog reset hook from main spec_helper.rb - Remove :skip_syslog_reset tags (no longer needed) The reset! method on Steno::Sink::Syslog remains as a clean API for test cleanup within the isolated steno test suite.
1 parent c74756f commit e4b8026

16 files changed

Lines changed: 7 additions & 23 deletions
File renamed without changes.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |file| require file }
66

7-
# Ensure syslog is closed after each steno test to avoid interfering with other tests
7+
# Ensure steno state is cleaned up after each test to avoid interfering with other tests
88
RSpec.configure do |config|
99
config.after do
10+
# Reset the Syslog singleton to clear any mocks stored in @syslog and @codec
11+
Steno::Sink::Syslog.instance.reset! if defined?(Steno::Sink::Syslog)
12+
13+
# Close the actual syslog connection if open
1014
Syslog.close if defined?(Syslog) && Syslog.opened?
1115
end
1216
end
File renamed without changes.
File renamed without changes.

spec/unit/lib/steno/support/shared_context_specs.rb renamed to spec/isolated_specs/steno/support/shared_context_specs.rb

File renamed without changes.

spec/unit/lib/steno/unit/config_spec.rb renamed to spec/isolated_specs/steno/unit/config_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'steno'
55

66
RSpec.describe Steno::Config do
7-
describe '.from_hash', :skip_syslog_reset do
7+
describe '.from_hash' do
88
before do
99
@log_path = 'some_file'
1010

@@ -113,7 +113,7 @@
113113
expect(config.sinks[0]).to eq(mock_sink)
114114
end
115115

116-
it "adds a syslog sink if the 'syslog' key is specified", :skip_syslog_reset do
116+
it "adds a syslog sink if the 'syslog' key is specified" do
117117
write_config(@config_path, { 'syslog' => 'test' })
118118
mock_sink = double('sink')
119119
expect(mock_sink).to receive(:open).with('test')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)