Skip to content

Commit 536084e

Browse files
committed
[rb] allow deprecation logging to provide link to additional references
1 parent 4b2db29 commit 536084e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

rb/lib/selenium/webdriver/common/logger.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ def warn(message, id: [])
108108
#
109109
# @param [String] old
110110
# @param [String, nil] new
111-
# @param [Symbol, Array<Sybmol>] id
111+
# @param [Symbol, Array<Symbol>] id
112+
# @param [String] reference
112113
# @yield appends additional message to end of provided template
113114
#
114-
def deprecate(old, new = nil, id: [], &block)
115+
def deprecate(old, new = nil, id: [], reference: '', &block)
115116
id = Array(id)
116117
return if @ignored.include?(:deprecations) || (@ignored & id).any?
117118

@@ -123,6 +124,8 @@ def deprecate(old, new = nil, id: [], &block)
123124
else
124125
' and will be removed in a future release.'
125126
end
127+
message << " See explanation for this deprecation: #{reference}." unless reference.empty?
128+
126129
warn message, &block
127130
end
128131

rb/spec/unit/selenium/webdriver/common/logger_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ module WebDriver
106106
expect { logger.deprecate('#old') }.to output(message).to_stdout_from_any_process
107107
end
108108

109+
it 'allows to deprecate functionality with a reference message' do
110+
ref_url = 'https://selenium.dev'
111+
warn_msg = 'WARN Selenium \[DEPRECATION\] #old is deprecated\. Use #new instead\.'
112+
message = /#{warn_msg} See explanation for this deprecation: #{ref_url}/
113+
expect { logger.deprecate('#old', '#new', reference: ref_url) }.to output(message).to_stdout_from_any_process
114+
end
115+
109116
it 'appends deprecation message with provided block' do
110117
message = /WARN Selenium \[DEPRECATION\] #old is deprecated\. Use #new instead\. More Details\./
111118
expect { logger.deprecate('#old', '#new') { 'More Details.' } }.to output(message).to_stdout_from_any_process

0 commit comments

Comments
 (0)