Skip to content

Commit c0fff14

Browse files
committed
Use Active Support’s silence_stream implementation
The old implementation has been removed from Rails because it was not thread safe. This commit replaces the old `silence_stream` implementation with the new one that we can actually find in Active Support. Refs: - rails/rails@481e49c - rails/rails#13392
1 parent 6fd265e commit c0fff14

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

spec/spec_helper.rb

+8-9
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ def silence
6868
end
6969
end
7070

71-
module Kernel
72-
def silence_stream(stream)
73-
old_stream = stream.dup
74-
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
75-
stream.sync = true
76-
yield
77-
ensure
78-
stream.reopen(old_stream)
79-
end
71+
def silence_stream(stream)
72+
old_stream = stream.dup
73+
stream.reopen(IO::NULL)
74+
stream.sync = true
75+
yield
76+
ensure
77+
stream.reopen(old_stream)
78+
old_stream.close
8079
end

0 commit comments

Comments
 (0)