diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2015-12-27 22:47:20 +0100 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2015-12-27 22:47:20 +0100 |
commit | 3a015c685233ec765551934bd9f1f9504c56fa46 (patch) | |
tree | 0f199db265b26b22ae2c5f3af1e62ec05f6f0a9d | |
parent | 2a3ee34e3ba2ea2e2d8eee23e4846c5a148693e2 (diff) | |
download | bundler-3a015c685233ec765551934bd9f1f9504c56fa46.tar.gz |
Add realworld specs for probing mirrors failing and falling back, all and specific
-rw-r--r-- | spec/realworld/mirror_probe_spec.rb | 89 |
1 files changed, 78 insertions, 11 deletions
diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb index c389097905..466b5ea5ab 100644 --- a/spec/realworld/mirror_probe_spec.rb +++ b/spec/realworld/mirror_probe_spec.rb @@ -9,25 +9,92 @@ describe "fetching dependencies with a not available mirror" do require_rack setup_mirror setup_server - 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) end after do @server_thread.kill end - it "install a gem using the original uri when the mirror is not responding" do - gemfile <<-G - source "#{original}" - gem 'weakling' - G + 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) + end - bundle :install + it "install a gem using the original uri when the mirror is not responding" do + gemfile <<-G + source "#{original}" + gem 'weakling' + G - expect(out).to include("Installing weakling") - expect(out).to include("Bundle complete") - should_be_installed "weakling 0.0.3" + bundle :install + + expect(out).to include("Installing weakling") + expect(out).to include("Bundle complete") + should_be_installed "weakling 0.0.3" + end + end + + context "with a global fallback timeout" do + before do + global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1", + "BUNDLE_MIRROR__ALL" => @mirror_uri) + end + + it "install a gem using the original uri when the mirror is not responding" do + gemfile <<-G + source "#{original}" + gem 'weakling' + G + + bundle :install + + expect(out).to include("Installing weakling") + expect(out).to include("Bundle complete") + should_be_installed "weakling 0.0.3" + end + end + + 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) + end + + it "fails to install the gem with a timeout error" do + gemfile <<-G + source "#{original}" + gem 'weakling' + G + + 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}") + end + end + + context "with a global mirror without a fallback timeout" do + before do + global_config("BUNDLE_MIRROR__ALL" => @mirror_uri) + end + + it "fails to install the gem with a timeout error" do + gemfile <<-G + source "#{original}" + gem 'weakling' + G + + 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}") + end end def setup_server |