Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed Net::HTTP adapter spec to be compatible with ruby 1.0

  • Loading branch information...
commit 123974b8ce92f5b572e3b41d573c6a33531b0f98 1 parent 623cf85
@bblimke authored
View
8 lib/webmock/http_lib_adapters/net_http.rb
@@ -33,8 +33,10 @@ def self.disable!
#in case any constants were added to @webMockNetHTTP instead of Net::HTTP
#after WebMock was enabled.
#i.e Net::HTTP::DigestAuth
- (@webMockNetHTTP.constants - OriginalNetHTTP.constants).each do |constant|
- OriginalNetHTTP.send(:const_set, constant, @webMockNetHTTP.const_get(constant))
+ @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
@@ -64,7 +66,7 @@ def const_get(name, inherit=true)
if Module.method(:constants).arity != 0
def constants(inherit=true)
- super + self.superclass.constants(inherit)
+ (super + self.superclass.constants(inherit)).uniq
end
end
end
View
2  spec/acceptance/net_http/net_http_spec.rb
@@ -92,7 +92,7 @@ class TestMarshalingInWebMockNetHTTP
WebMock.enable!
end
it "Net::HTTP should have the same constants" do
- orig_consts_number = Net::HTTP.constants.size
+ orig_consts_number = WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP.constants.size
Net::HTTP.send(:const_set, "TEST_CONST", 10)
Net::HTTP.constants.size.should == orig_consts_number + 1
WebMock.disable!
Please sign in to comment.
Something went wrong with that request. Please try again.