Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

No need for this global "seen request" tracking now that we're handli…

…ng Net::HTTP's recursion directly.
  • Loading branch information...
commit 0b17104a746f48db0ca1794a91ffce1a4eb222ee 1 parent 22915c4
Myron Marston authored July 09, 2012
21  lib/vcr/library_hooks/fakeweb.rb
@@ -26,33 +26,12 @@ def handle
26 26
           invoke_after_request_hook(@vcr_response) unless @recursing
27 27
         end
28 28
 
29  
-        class << self
30  
-          def already_seen_requests
31  
-            @@already_seen_requests ||= Set.new
32  
-          end
33  
-        end
34  
-
35 29
       private
36 30
 
37 31
         def externally_stubbed?
38 32
           ::FakeWeb.registered_uri?(request_method, uri)
39 33
         end
40 34
 
41  
-        def invoke_before_request_hook
42  
-          unless self.class.already_seen_requests.include?(request.object_id)
43  
-            super
44  
-            # we use the object_id so that if there is bug that causes
45  
-            # us not to fully cleanup, we'll only be leaking the memory
46  
-            # of one integer, not the whole request object.
47  
-            self.class.already_seen_requests << request.object_id
48  
-          end
49  
-        end
50  
-
51  
-        def invoke_after_request_hook(vcr_response)
52  
-          self.class.already_seen_requests.delete(request.object_id)
53  
-          super
54  
-        end
55  
-
56 35
         def on_externally_stubbed_request
57 36
           # just perform the request--FakeWeb will handle it
58 37
           perform_request(:started)
11  spec/vcr/library_hooks/fakeweb_spec.rb
@@ -18,16 +18,7 @@ def directly_stub_request(method, url, response_body)
18 18
     ::FakeWeb.register_uri(method, url, :body => response_body)
19 19
   end
20 20
 
21  
-  it_behaves_like 'a hook into an HTTP library', :fakeweb, 'net/http' do
22  
-    before(:each) do
23  
-      VCR::LibraryHooks::FakeWeb::RequestHandler.already_seen_requests.clear
24  
-    end
25  
-
26  
-    after(:each) do
27  
-      # assert that we are cleaning up the global state after every request
28  
-      VCR::LibraryHooks::FakeWeb::RequestHandler.already_seen_requests.to_a.should eq([])
29  
-    end
30  
-  end
  21
+  it_behaves_like 'a hook into an HTTP library', :fakeweb, 'net/http'
31 22
 
32 23
   describe "some specific Net::HTTP edge cases" do
33 24
     before(:each) do

0 notes on commit 0b17104

Please sign in to comment.
Something went wrong with that request. Please try again.