Skip to content

Commit 9422b41

Browse files
committed
Use StringIO instead of Tempfile for suppressing STDOUT
The latter might be closed and raise <IOError: closed stream> when reading
1 parent cf09d58 commit 9422b41

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

rb/spec/rspec_matchers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
match do |actual|
2222
# Suppresses logging output to stdout while ensuring that it is still happening
2323
default_output = Selenium::WebDriver.logger.io
24-
tempfile = Tempfile.new
25-
Selenium::WebDriver.logger.output = tempfile
24+
io = StringIO.new
25+
Selenium::WebDriver.logger.output = io
2626

2727
actual.call
2828

2929
Selenium::WebDriver.logger.output = default_output
30-
@deprecations_found = (tempfile.rewind && tempfile.read).scan(/DEPRECATION\] \[:([^\]]*)\]/).flatten.map(&:to_sym)
30+
@deprecations_found = (io.rewind && io.read).scan(/DEPRECATION\] \[:([^\]]*)\]/).flatten.map(&:to_sym)
3131
expect(Array(deprecation).sort).to eq(@deprecations_found.sort)
3232
end
3333

0 commit comments

Comments
 (0)