diff options
Diffstat (limited to 'spec/bundler/cache/gems_spec.rb')
-rw-r--r-- | spec/bundler/cache/gems_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb index 7828c87fec..4a0b953830 100644 --- a/spec/bundler/cache/gems_spec.rb +++ b/spec/bundler/cache/gems_spec.rb @@ -1,15 +1,14 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle cache" do - describe "when there are only gemsources" do + shared_examples_for "when there are only gemsources" do before :each do gemfile <<-G gem 'rack' G - system_gems "rack-1.0.0" - bundle :cache + system_gems "rack-1.0.0", :path => :bundle_path + bundle! :cache end it "copies the .gem file to vendor/cache" do @@ -28,7 +27,7 @@ RSpec.describe "bundle cache" do end it "uses the cache as a source when installing gems with --local" do - system_gems [] + system_gems [], :path => :bundle_path bundle "install --local" expect(the_bundle).to include_gems("rack 1.0.0") @@ -47,7 +46,7 @@ RSpec.describe "bundle cache" do end it "does not reinstall gems from the cache if they exist in the bundle" do - system_gems "rack-1.0.0" + system_gems "rack-1.0.0", :path => :bundle_path gemfile <<-G gem "rack" @@ -57,7 +56,7 @@ RSpec.describe "bundle cache" do s.write "lib/rack.rb", "RACK = 'FAIL'" end - bundle "install --local" + bundle! :install, :local => true expect(the_bundle).to include_gems("rack 1.0.0") end @@ -74,6 +73,16 @@ RSpec.describe "bundle cache" do end end + context "using system gems" do + before { bundle! "config path.system true" } + it_behaves_like "when there are only gemsources" + end + + context "installing into a local path" do + before { bundle! "config path ./.bundle" } + it_behaves_like "when there are only gemsources" + end + describe "when there is a built-in gem", :ruby => "2.0" do before :each do build_repo2 do @@ -87,7 +96,8 @@ RSpec.describe "bundle cache" do FileUtils.rm("#{system_gem_path}/cache/builtin_gem-1.0.2.gem") end - it "uses builtin gems" do + it "uses builtin gems when installing to system gems" do + bundle! "config path.system true" install_gemfile %(gem 'builtin_gem', '1.0.2') expect(the_bundle).to include_gems("builtin_gem 1.0.2") end @@ -119,6 +129,8 @@ RSpec.describe "bundle cache" do end it "errors if the builtin gem isn't available to cache" do + bundle! "config path.system true" + install_gemfile <<-G gem 'builtin_gem', '1.0.2' G @@ -184,7 +196,7 @@ RSpec.describe "bundle cache" do it "adds and removes when gems are updated" do update_repo2 - bundle "update" + bundle "update", :all => bundle_update_requires_all? expect(cached_gem("rack-1.2")).to exist expect(cached_gem("rack-1.0.0")).not_to exist end |