summaryrefslogtreecommitdiff
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
parent3c643eafd76c1514aa9ce565e7754cf5049f483d (diff)
downloadbundler-b40745584bcba89dce042b5b28bb84b1de1d3d48.tar.gz
Get the realworld specs running on 1.8.7 again
-rw-r--r--spec/realworld/dependency_api_spec.rb8
-rw-r--r--spec/realworld/gemfile_source_header_spec.rb2
-rw-r--r--spec/realworld/mirror_probe_spec.rb10
-rw-r--r--spec/support/artifice/endpoint_timeout.rb2
-rw-r--r--spec/support/artifice/vcr.rb21
5 files changed, 24 insertions, 19 deletions
diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb
index f57a9be65e..13527ce5d1 100644
--- a/spec/realworld/dependency_api_spec.rb
+++ b/spec/realworld/dependency_api_spec.rb
@@ -22,6 +22,7 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
@t.run
wait_for_server("127.0.0.1", port)
+ bundle! "config timeout 1"
end
after do
@@ -31,16 +32,11 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
end
it "times out and falls back on the modern index" do
- gemfile <<-G
+ install_gemfile! <<-G, :artifice => nil
source "#{@server_uri}"
gem "rack"
-
- old_v, $VERBOSE = $VERBOSE, nil
- Bundler::Fetcher.api_timeout = 1
- $VERBOSE = old_v
G
- bundle :install
expect(out).to include("Fetching source index from #{@server_uri}/")
expect(the_bundle).to include_gems "rack 1.0.0"
end
diff --git a/spec/realworld/gemfile_source_header_spec.rb b/spec/realworld/gemfile_source_header_spec.rb
index 4cb04a81a6..aeb21348fc 100644
--- a/spec/realworld/gemfile_source_header_spec.rb
+++ b/spec/realworld/gemfile_source_header_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe "fetching dependencies with a mirrored source", :realworld => tru
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb
index df49cd53ee..9ca726f781 100644
--- a/spec/realworld/mirror_probe_spec.rb
+++ b/spec/realworld/mirror_probe_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
@@ -51,7 +51,7 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
@@ -70,7 +70,7 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to include("Fetching source index from #{mirror}")
expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
@@ -85,7 +85,7 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to eq "Fetching source index from #{mirror}/
@@ -107,7 +107,7 @@ Could not fetch specs from #{mirror}/"
gem 'weakling'
G
- bundle :install
+ bundle :install, :artifice => nil
expect(out).to include("Fetching source index from #{mirror}")
expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
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