Skip to content

Commit 136c2e9

Browse files
committed
[rb] more precise implementation of checking for deprecations in specs
1 parent 1ed6eb5 commit 136c2e9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

rb/spec/rspec_matchers.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919

2020
RSpec::Matchers.define :have_deprecated do |deprecation|
2121
match do |actual|
22-
# Not sure how else to capture stdout here
23-
expect {
24-
actual.call
25-
std_out = File.read $stdout if $stdout.is_a?(File)
26-
@deprecations_found = std_out&.scan(/DEPRECATION\] \[:([^\]]*)\]/)&.flatten&.map(&:to_sym)
27-
}.to output.to_stdout_from_any_process
28-
expect(Array(deprecation).sort).to eq(@deprecations_found&.sort)
22+
# Suppresses logging output to stdout while ensuring that it is still happening
23+
default_output = Selenium::WebDriver.logger.io
24+
tempfile = Tempfile.new
25+
Selenium::WebDriver.logger.output = tempfile
26+
27+
actual.call
28+
29+
Selenium::WebDriver.logger.output = default_output
30+
@deprecations_found = (tempfile.rewind && tempfile.read).scan(/DEPRECATION\] \[:([^\]]*)\]/).flatten.map(&:to_sym)
31+
expect(Array(deprecation).sort).to eq(@deprecations_found.sort)
2932
end
3033

3134
failure_message do

0 commit comments

Comments
 (0)