Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix spec failing on 1.8.7.

Weirdly, it appears that on 1.8.7, Array#delete will return the object you pass to it rather than the object in the array!

O = Struct.new(:a, :b)
i1, i2 = O.new(3, 5), O.new(3, 5)
list = [i1]
deleted = list.delete(i2)

deleted.equal?(i1) # => true on 1.9.2, false on 1.8.7
deleted.equal?(i2) # => false on 1.9.2, true on 1.8.7
  • Loading branch information...
commit 40f1f4820315a066358fd9e1dda04d3cac97a266 1 parent c4204cd
@myronmarston myronmarston authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/webmock/http_lib_adapters/httpclient_adapter.rb
View
7 lib/webmock/http_lib_adapters/httpclient_adapter.rb
@@ -158,7 +158,7 @@ def build_request_signature(req, reuse_existing = false)
)
# reuse a previous identical signature object if we stored one for later use
- if reuse_existing && previous_signature = webmock_request_signatures.delete(signature)
+ if reuse_existing && previous_signature = previous_signature_for(signature)
return previous_signature
end
@@ -175,4 +175,9 @@ def webmock_request_signatures
@webmock_request_signatures ||= []
end
+ def previous_signature_for(signature)
+ return nil unless index = webmock_request_signatures.index(signature)
+ webmock_request_signatures.delete_at(index)
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.