Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix broken cukes.

We can't have different adapters return different values for #normalize_uri because it breaks when you stub with multiple libraries.
  • Loading branch information...
commit 70b195f2995e6f3b2edc328b320c3125ad93b48d 1 parent 0d4d9f5
Myron Marston authored March 05, 2011
5  lib/vcr/http_stubbing_adapters/common.rb
@@ -67,11 +67,6 @@ def restore_stubs_checkpoint(cassette)
67 67
         raise ArgumentError.new("No checkpoint for #{cassette.inspect} could be found")
68 68
       end
69 69
 
70  
-      def normalize_uri(uri)
71  
-        # the adapters can implement this if they want
72  
-        uri
73  
-      end
74  
-
75 70
       private
76 71
 
77 72
       def compare_version
16  lib/vcr/http_stubbing_adapters/faraday.rb
@@ -26,7 +26,8 @@ def uri_should_be_ignored?(uri)
26 26
 
27 27
       def stub_requests(http_interactions, match_attributes)
28 28
         grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
29  
-          queue = stub_queues[request_matcher]
  29
+          matcher = request_matcher_with_normalized_uri(request_matcher)
  30
+          queue = stub_queues[matcher]
30 31
           responses.each { |res| queue << res }
31 32
         end
32 33
       end
@@ -51,10 +52,6 @@ def reset!
51 52
         end
52 53
       end
53 54
 
54  
-      def normalize_uri(uri)
55  
-        super.gsub('+', '%20')
56  
-      end
57  
-
58 55
       private
59 56
 
60 57
         def version
@@ -86,6 +83,15 @@ def stub_queue_dup
86 83
         def hash_of_arrays
87 84
           Hash.new { |h, k| h[k] = [] }
88 85
         end
  86
+
  87
+        def request_matcher_with_normalized_uri(matcher)
  88
+          return matcher unless matcher.uri.is_a?(String) && matcher.uri.include?('+')
  89
+
  90
+          request = matcher.request.dup
  91
+          request.uri = request.uri.gsub('+', '%20')
  92
+
  93
+          RequestMatcher.new(request, matcher.match_attributes)
  94
+        end
89 95
     end
90 96
   end
91 97
 end
2  lib/vcr/structs/normalizers/uri.rb
@@ -27,7 +27,7 @@ def normalize_uri
27 27
         # urls have always included it).  We force it to be included
28 28
         # here by redefining default_port so that URI#to_s will include it.
29 29
         def u.default_port; nil; end
30  
-        self.uri = VCR.http_stubbing_adapter.normalize_uri(u.to_s)
  30
+        self.uri = u.to_s
31 31
       end
32 32
     end
33 33
   end

0 notes on commit 70b195f

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