Class: WebMock::HttpLibAdapters::NetHttpAdapter
- Inherits:
-
WebMock::HttpLibAdapter
- Object
- WebMock::HttpLibAdapter
- WebMock::HttpLibAdapters::NetHttpAdapter
- Defined in:
- lib/webmock/http_lib_adapters/net_http.rb
Constant Summary collapse
- OriginalNetHTTP =
Net::HTTP
Class Method Summary collapse
Methods inherited from WebMock::HttpLibAdapter
Class Method Details
.disable! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/webmock/http_lib_adapters/net_http.rb', line 21 def self.disable! Net.send(:remove_const, :HTTP) Net.send(:remove_const, :HTTPSession) Net.send(:const_set, :HTTP, OriginalNetHTTP) Net.send(:const_set, :HTTPSession, OriginalNetHTTP) #copy all constants from @webMockNetHTTP to original Net::HTTP #in case any constants were added to @webMockNetHTTP instead of Net::HTTP #after WebMock was enabled. #i.e Net::HTTP::DigestAuth @webMockNetHTTP.constants.each do |constant| if !OriginalNetHTTP.constants.map(&:to_s).include?(constant.to_s) OriginalNetHTTP.send(:const_set, constant, @webMockNetHTTP.const_get(constant)) end end end |