diff --git a/lib/webmock/http_lib_adapters/net_http.rb b/lib/webmock/http_lib_adapters/net_http.rb index ed62ed3ec..dee0dd173 100644 --- a/lib/webmock/http_lib_adapters/net_http.rb +++ b/lib/webmock/http_lib_adapters/net_http.rb @@ -74,6 +74,12 @@ def socket_type_with_webmock end alias_method :socket_type_without_webmock, :socket_type alias_method :socket_type, :socket_type_with_webmock + + if ::RUBY_VERSION =~ /1.8/ + def const_defined?(name) + super || self.superclass.const_defined?(name) + end + end end def request_with_webmock(request, body = nil, &block) diff --git a/spec/net_http_spec.rb b/spec/net_http_spec.rb index bb5e4324e..91bd2eb91 100644 --- a/spec/net_http_spec.rb +++ b/spec/net_http_spec.rb @@ -11,6 +11,10 @@ let(:port){ WebMockServer.instance.port } + it "should still have const Get defined on replaced Net::HTTP" do + Object.const_get("Net").const_get("HTTP").const_defined?("Get").should be_true + end + it "should work with block provided" do stub_http_request(:get, "www.example.com").to_return(:body => "abc"*100000) Net::HTTP.start("www.example.com") { |query| query.get("/") }.body.should == "abc"*100000