-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve net-http
adapter deprecation Ruby 3.4
#1081
base: master
Are you sure you want to change the base?
Conversation
4cfa886
to
720c41c
Compare
720c41c
to
f58b1f8
Compare
Slight gearshift. The constant will be kept for 3.4 but will warn on removal, see https://bugs.ruby-lang.org/issues/20900. I adapted the code to not warn and handle the const removal. |
def self.remove_silently(mod, const) #:nodoc: | ||
begin | ||
# Don't warn on removing the deprecated constant | ||
verbose, $VERBOSE = $VERBOSE, nil | ||
mod.send(:remove_const, const) | ||
ensure | ||
$VERBOSE = verbose | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My two cents, WebMock supports Ruby 2.5+, the redundant begin
should no longer be necessary.
https://github.com/bblimke/webmock/blob/v3.24.0/webmock.gemspec#L24
def self.remove_silently(mod, const) #:nodoc: | |
begin | |
# Don't warn on removing the deprecated constant | |
verbose, $VERBOSE = $VERBOSE, nil | |
mod.send(:remove_const, const) | |
ensure | |
$VERBOSE = verbose | |
end | |
end | |
def self.remove_silently(mod, const) #:nodoc: | |
# Don't warn on removing the deprecated constant. | |
verbose, $VERBOSE = $VERBOSE, nil | |
mod.send(:remove_const, const) | |
ensure | |
$VERBOSE = verbose | |
end |
This old constant was deprecated in 2001 and will now be removed in Ruby 3.5 On Ruby 3.4, removing a deprecated constant will warn: > /home/user/code/webmock/lib/webmock/http_lib_adapters/net_http.rb:55: warning: constant Net::HTTPSession is deprecated It fixes this error on Ruby 3.5: ``` /usr/local/bundle/bundler/gems/webmock-9ff63ac7c845/lib/webmock/http_lib_adapters/net_http.rb:25:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) Net.send(:remove_const, :HTTPSession) ^^^^^ from /usr/local/bundle/bundler/gems/webmock-9ff63ac7c845/lib/webmock/http_lib_adapters/net_http.rb:25:in 'WebMock::HttpLibAdapters::NetHttpAdapter.disable!' ```
f58b1f8
to
67c0695
Compare
net-http
adapter for Ruby 3.4net-http
adapter deprecation Ruby 3.4
@bblimke could you check this out? The next Ruby version is only about 2 weeks away now. |
Hello 😃, All Rails apps that try to update to Ruby 3.4.1 will see a warning because of this 😅. |
This old constant was deprecated in 2001 and now finally removed. ruby/net-http#189
It fixes this error:
You can test it yourself by adding
gem 'net-http', github: 'ruby/net-http'
to the gemfile here and running tests.I assume this will be released with 3.4