diff options
Diffstat (limited to 'spec/bundler/commands/cache_spec.rb')
-rw-r--r-- | spec/bundler/commands/cache_spec.rb | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index df027a497a..70e2c84961 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -158,7 +158,7 @@ RSpec.describe "bundle cache" do end end - context "with --path", :bundler => "< 3" do + context "with --path", bundler: "< 3" do it "sets root directory for gems" do gemfile <<-D source "#{file_uri_for(gem_repo1)}" @@ -211,7 +211,17 @@ RSpec.describe "bundle cache" do end context "with --all-platforms" do - it "puts the gems in vendor/cache even for other rubies" do + it "puts the gems in vendor/cache even for other rubies", bundler: ">= 2.4.0" do + gemfile <<-D + source "#{file_uri_for(gem_repo1)}" + gem 'rack', :platforms => [:ruby_20, :windows_20] + D + + bundle "cache --all-platforms" + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + end + + it "puts the gems in vendor/cache even for legacy windows rubies", bundler: ">= 2.4.0" do gemfile <<-D source "#{file_uri_for(gem_repo1)}" gem 'rack', :platforms => [:ruby_20, :x64_mingw_20] @@ -262,7 +272,7 @@ RSpec.describe "bundle cache" do end G - bundle :lock, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + bundle :lock, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } bundle :cache, "all-platforms" => true, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist end @@ -279,7 +289,7 @@ RSpec.describe "bundle cache" do subject do bundle "config set --local frozen true" - bundle :cache, :raise_on_error => false + bundle :cache, raise_on_error: false end it "tries to install with frozen" do @@ -291,13 +301,37 @@ RSpec.describe "bundle cache" do G subject expect(exitstatus).to eq(16) - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") bundle "env" expect(out).to include("frozen").or include("deployment") end end + + context "with gems with extensions" do + before do + build_repo2 do + build_gem "racc", "2.0" do |s| + s.add_dependency "rake" + s.extensions << "Rakefile" + s.write "Rakefile", "task(:default) { puts 'INSTALLING rack' }" + end + end + + gemfile <<~G + source "#{file_uri_for(gem_repo2)}" + + gem "racc" + G + end + + it "installs them properly from cache to a different path" do + bundle "cache" + bundle "config set --local path vendor/bundle" + bundle "install --local" + end + end end RSpec.describe "bundle install with gem sources" do @@ -317,7 +351,7 @@ RSpec.describe "bundle install with gem sources" do expect(the_bundle).to include_gems "rack 1.0.0" end - it "does not hit the remote at all" do + it "does not hit the remote at all in frozen mode" do build_repo2 install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -334,6 +368,24 @@ RSpec.describe "bundle install with gem sources" do expect(the_bundle).to include_gems "rack 1.0.0" end + it "does not hit the remote at all when cache_all_platforms configured" do + build_repo2 + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "rack" + G + + bundle :cache + simulate_new_machine + FileUtils.rm_rf gem_repo2 + + bundle "config set --local cache_all_platforms true" + bundle "config set --local path vendor/bundle" + bundle "install --local" + expect(out).not_to include("Fetching gem metadata") + expect(the_bundle).to include_gems "rack 1.0.0" + end + it "does not reinstall already-installed gems" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -341,7 +393,7 @@ RSpec.describe "bundle install with gem sources" do G bundle :cache - build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s| + build_gem "rack", "1.0.0", path: bundled_app("vendor/cache") do |s| s.write "lib/rack.rb", "raise 'omg'" end @@ -361,14 +413,14 @@ RSpec.describe "bundle install with gem sources" do simulate_new_machine - simulate_platform "ruby" do - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "platform_specific" - G - run "require 'platform_specific' ; puts PLATFORM_SPECIFIC" - expect(out).to eq("1.0.0 RUBY") - end + bundle "config set --local force_ruby_platform true" + + install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "platform_specific" + G + run "require 'platform_specific' ; puts PLATFORM_SPECIFIC" + expect(out).to eq("1.0.0 RUBY") end it "does not update the cache if --no-cache is passed" do |