diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2015-12-28 00:18:16 +0100 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2015-12-28 00:18:16 +0100 |
commit | c42a9e451ccb2a503950317ae0eb4fc5aed379f8 (patch) | |
tree | 9e63b956bbd2e391cb15777d653bc7b0fc871801 /spec/realworld | |
parent | fe09d51601fea21cb9c3244868ba01ee7c5f7b56 (diff) | |
download | bundler-c42a9e451ccb2a503950317ae0eb4fc5aed379f8.tar.gz |
Use late binding for ports in the rack based specs to prevent picking wrong ports
Diffstat (limited to 'spec/realworld')
-rw-r--r-- | spec/realworld/mirror_probe_spec.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb index 28c5e66d55..cc5a2778ed 100644 --- a/spec/realworld/mirror_probe_spec.rb +++ b/spec/realworld/mirror_probe_spec.rb @@ -4,11 +4,13 @@ require "thread" describe "fetching dependencies with a not available mirror", :realworld => true do let(:mirror) { @mirror_uri } let(:original) { @server_uri } + let(:server_port) { @server_port } + let(:host) { "127.0.0.1" } before do require_rack - setup_mirror setup_server + setup_mirror end after do @@ -17,8 +19,8 @@ describe "fetching dependencies with a not available mirror", :realworld => true context "with a specific fallback timeout" do before do - global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/__FALLBACK_TIMEOUT/" => "true", - "BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri) + global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/__FALLBACK_TIMEOUT/" => "true", + "BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror) end it "install a gem using the original uri when the mirror is not responding" do @@ -38,7 +40,7 @@ describe "fetching dependencies with a not available mirror", :realworld => true context "with a global fallback timeout" do before do global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1", - "BUNDLE_MIRROR__ALL" => @mirror_uri) + "BUNDLE_MIRROR__ALL" => mirror) end it "install a gem using the original uri when the mirror is not responding" do @@ -57,7 +59,7 @@ describe "fetching dependencies with a not available mirror", :realworld => true context "with a specific mirror without a fallback timeout" do before do - global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri) + global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror) end it "fails to install the gem with a timeout error" do @@ -68,17 +70,17 @@ describe "fetching dependencies with a not available mirror", :realworld => true bundle :install - expect(out).to include("Fetching source index from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Could not fetch specs from #{@mirror_uri}") + 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}") + expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}") + expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}") + expect(out).to include("Could not fetch specs from #{mirror}") end end context "with a global mirror without a fallback timeout" do before do - global_config("BUNDLE_MIRROR__ALL" => @mirror_uri) + global_config("BUNDLE_MIRROR__ALL" => mirror) end it "fails to install the gem with a timeout error" do @@ -89,35 +91,33 @@ describe "fetching dependencies with a not available mirror", :realworld => true bundle :install - expect(out).to include("Fetching source index from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}") - expect(out).to include("Could not fetch specs from #{@mirror_uri}") + 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}") + expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}") + expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}") + expect(out).to include("Could not fetch specs from #{mirror}") end end def setup_server @server_port = find_unused_port - @server_host = "127.0.0.1" - @server_uri = "http://#{@server_host}:#{@server_port}" + @server_uri = "http://#{host}:#{@server_port}" require File.expand_path("../../support/artifice/endpoint", __FILE__) @server_thread = Thread.new do Rack::Server.start(:app => Endpoint, - :Host => @server_host, + :Host => host, :Port => @server_port, :server => "webrick", :AccessLog => []) end.run - wait_for_server(@server_host, @server_port) + wait_for_server(@host, @server_port) end def setup_mirror - @mirror_port = find_unused_port - @mirror_host = "127.0.0.1" - @mirror_uri = "http://#{@mirror_host}:#{@mirror_port}" + mirror_port = find_unused_port + @mirror_uri = "http://#{host}:#{mirror_port}" end end |