Skip to content

Commit

Permalink
Fix broken cukes.
Browse files Browse the repository at this point in the history
We can't have different adapters return different values for #normalize_uri because it breaks when you stub with multiple libraries.
  • Loading branch information
myronmarston committed Mar 6, 2011
1 parent 0d4d9f5 commit 70b195f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lib/vcr/http_stubbing_adapters/common.rb
Expand Up @@ -67,11 +67,6 @@ def restore_stubs_checkpoint(cassette)
raise ArgumentError.new("No checkpoint for #{cassette.inspect} could be found")
end

def normalize_uri(uri)
# the adapters can implement this if they want
uri
end

private

def compare_version
Expand Down
16 changes: 11 additions & 5 deletions lib/vcr/http_stubbing_adapters/faraday.rb
Expand Up @@ -26,7 +26,8 @@ def uri_should_be_ignored?(uri)

def stub_requests(http_interactions, match_attributes)
grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
queue = stub_queues[request_matcher]
matcher = request_matcher_with_normalized_uri(request_matcher)
queue = stub_queues[matcher]
responses.each { |res| queue << res }
end
end
Expand All @@ -51,10 +52,6 @@ def reset!
end
end

def normalize_uri(uri)
super.gsub('+', '%20')
end

private

def version
Expand Down Expand Up @@ -86,6 +83,15 @@ def stub_queue_dup
def hash_of_arrays
Hash.new { |h, k| h[k] = [] }
end

def request_matcher_with_normalized_uri(matcher)
return matcher unless matcher.uri.is_a?(String) && matcher.uri.include?('+')

request = matcher.request.dup
request.uri = request.uri.gsub('+', '%20')

RequestMatcher.new(request, matcher.match_attributes)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vcr/structs/normalizers/uri.rb
Expand Up @@ -27,7 +27,7 @@ def normalize_uri
# urls have always included it). We force it to be included
# here by redefining default_port so that URI#to_s will include it.
def u.default_port; nil; end
self.uri = VCR.http_stubbing_adapter.normalize_uri(u.to_s)
self.uri = u.to_s
end
end
end
Expand Down

0 comments on commit 70b195f

Please sign in to comment.