summaryrefslogtreecommitdiff
path: root/spec/support/artifice
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-12-25 17:24:49 -0600
committerSamuel Giddins <segiddins@segiddins.me>2017-06-13 11:12:22 -0500
commitb40745584bcba89dce042b5b28bb84b1de1d3d48 (patch)
tree4ffe7dc75227bf7b82f40c2b016171b46ab0420b /spec/support/artifice
parent3c643eafd76c1514aa9ce565e7754cf5049f483d (diff)
downloadbundler-b40745584bcba89dce042b5b28bb84b1de1d3d48.tar.gz
Get the realworld specs running on 1.8.7 again
Diffstat (limited to 'spec/support/artifice')
-rw-r--r--spec/support/artifice/endpoint_timeout.rb2
-rw-r--r--spec/support/artifice/vcr.rb21
2 files changed, 16 insertions, 7 deletions
diff --git a/spec/support/artifice/endpoint_timeout.rb b/spec/support/artifice/endpoint_timeout.rb
index b15650f226..f2349bd5c7 100644
--- a/spec/support/artifice/endpoint_timeout.rb
+++ b/spec/support/artifice/endpoint_timeout.rb
@@ -4,7 +4,7 @@ require File.expand_path("../endpoint_fallback", __FILE__)
Artifice.deactivate
class EndpointTimeout < EndpointFallback
- SLEEP_TIMEOUT = 15
+ SLEEP_TIMEOUT = 3
get "/api/v1/dependencies" do
sleep(SLEEP_TIMEOUT)
diff --git a/spec/support/artifice/vcr.rb b/spec/support/artifice/vcr.rb
index a4ae34ba92..576fe57d82 100644
--- a/spec/support/artifice/vcr.rb
+++ b/spec/support/artifice/vcr.rb
@@ -43,8 +43,8 @@ class BundlerVCRHTTP < Net::HTTP
File.open(request_pair_paths.last, "rb:ASCII-8BIT") do |response_file|
response_io = ::Net::BufferedIO.new(response_file)
::Net::HTTPResponse.read_new(response_io).tap do |response|
- response.decode_content = request.decode_content
- response.uri = request.uri
+ response.decode_content = request.decode_content if request.respond_to?(:decode_content)
+ response.uri = request.uri if request.respond_to?(:uri)
response.reading_body(response_io, request.response_body_permitted?) do
response_block.call(response) if response_block
@@ -62,14 +62,14 @@ class BundlerVCRHTTP < Net::HTTP
@recording = false
unless @recording
FileUtils.mkdir_p(File.dirname(request_path))
- File.binwrite(request_path, request_to_string(request))
- File.binwrite(response_path, response_to_string(response))
+ binwrite(request_path, request_to_string(request))
+ binwrite(response_path, response_to_string(response))
end
response
end
def key
- [request.uri, request["host"] || http.address, request.path, request.method].compact
+ [request["host"] || http.address, request.path, request.method].compact
end
def file_name_for_key(key)
@@ -124,7 +124,16 @@ class BundlerVCRHTTP < Net::HTTP
response_string << "" << body
- response_string.join("\n").force_encoding("ASCII-8BIT")
+ response_string = response_string.join("\n")
+ if response_string.respond_to?(:force_encoding)
+ response_string.force_encoding("ASCII-8BIT")
+ else
+ response_string
+ end
+ end
+
+ def binwrite(path, contents)
+ File.open(path, "wb:ASCII-8BIT") {|f| f.write(contents) }
end
end