Skip to content

Commit

Permalink
Use StringIO instead of Tempfile for suppressing STDOUT
Browse files Browse the repository at this point in the history
The latter might be closed and raise <IOError: closed stream> when
reading
  • Loading branch information
p0deje committed May 28, 2020
1 parent cf09d58 commit 9422b41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rb/spec/rspec_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
match do |actual|
# Suppresses logging output to stdout while ensuring that it is still happening
default_output = Selenium::WebDriver.logger.io
tempfile = Tempfile.new
Selenium::WebDriver.logger.output = tempfile
io = StringIO.new
Selenium::WebDriver.logger.output = io

actual.call

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

Expand Down

0 comments on commit 9422b41

Please sign in to comment.