File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 19
19
20
20
RSpec ::Matchers . define :have_deprecated do |deprecation |
21
21
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 )
29
32
end
30
33
31
34
failure_message do
You can’t perform that action at this time.
0 commit comments