Resolve net-http adapter deprecation Ruby 3.4#1081
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.
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 😅. |
|
@bblimke Thank you for your maintenance efforts. Ruby 3.4.1 has been released. Could you release this at your convenience? |
|
🙏 for release, change looks good and was successfully tested with rubygems.org codebase. |
|
WebMock 3.25.0 has been released. Thank you. |
|
@koic thanks for taking over maintenance, much appreciated! |
This resolves the deprecation warning ``` warning: constant Net::HTTPSession is deprecated ``` See: - bblimke/webmock#1088 - bblimke/webmock#1081 - ruby/net-http#189
This resolves the deprecation warning ``` warning: constant Net::HTTPSession is deprecated ``` See: - bblimke/webmock#1088 - bblimke/webmock#1081 - ruby/net-http#189
This resolves the deprecation warning ``` warning: constant Net::HTTPSession is deprecated ``` See: - bblimke/webmock#1088 - bblimke/webmock#1081 - ruby/net-http#189
Closes #1088
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