diff options
Diffstat (limited to 'spec/bundler/cache/path_spec.rb')
| -rw-r--r-- | spec/bundler/cache/path_spec.rb | 192 |
1 files changed, 87 insertions, 105 deletions
diff --git a/spec/bundler/cache/path_spec.rb b/spec/bundler/cache/path_spec.rb index 8c6a843476..42648aea1f 100644 --- a/spec/bundler/cache/path_spec.rb +++ b/spec/bundler/cache/path_spec.rb @@ -1,139 +1,121 @@ # frozen_string_literal: true -%w[cache package].each do |cmd| - RSpec.describe "bundle #{cmd} with path" do - it "is no-op when the path is within the bundle" do - build_lib "foo", :path => bundled_app("lib/foo") - - install_gemfile <<-G - gem "foo", :path => '#{bundled_app("lib/foo")}' - G - - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - expect(bundled_app("vendor/cache/foo-1.0")).not_to exist - expect(the_bundle).to include_gems "foo 1.0" - end - - it "copies when the path is outside the bundle " do - build_lib "foo" - - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G +RSpec.describe "bundle cache with path" do + it "is no-op when the path is within the bundle" do + build_lib "foo", path: bundled_app("lib/foo") + + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{bundled_app("lib/foo")}' + G + + bundle :cache + expect(bundled_app("vendor/cache/foo-1.0")).not_to exist + expect(the_bundle).to include_gems "foo 1.0" + end - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - expect(bundled_app("vendor/cache/foo-1.0")).to exist - expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file + it "copies when the path is outside the bundle " do + build_lib "foo" - FileUtils.rm_rf lib_path("foo-1.0") - expect(the_bundle).to include_gems "foo 1.0" - end + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{lib_path("foo-1.0")}' + G - it "copies when the path is outside the bundle and the paths intersect" do - libname = File.basename(Dir.pwd) + "_gem" - libpath = File.join(File.dirname(Dir.pwd), libname) + bundle :cache + expect(bundled_app("vendor/cache/foo-1.0")).to exist + expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file - build_lib libname, :path => libpath - - install_gemfile <<-G - gem "#{libname}", :path => '#{libpath}' - G + expect(the_bundle).to include_gems "foo 1.0" + end - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - expect(bundled_app("vendor/cache/#{libname}")).to exist - expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file + it "copies when the path is outside the bundle and the paths intersect" do + libname = File.basename(bundled_app) + "_gem" + libpath = File.join(File.dirname(bundled_app), libname) - FileUtils.rm_rf libpath - expect(the_bundle).to include_gems "#{libname} 1.0" - end + build_lib libname, path: libpath - it "updates the path on each cache" do - build_lib "foo" + install_gemfile <<-G + source "https://gem.repo1" + gem "#{libname}", :path => '#{libpath}' + G - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G + bundle :cache + expect(bundled_app("vendor/cache/#{libname}")).to exist + expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + expect(the_bundle).to include_gems "#{libname} 1.0" + end - build_lib "foo" do |s| - s.write "lib/foo.rb", "puts :CACHE" - end + it "updates the path on each cache" do + build_lib "foo" - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{lib_path("foo-1.0")}' + G - expect(bundled_app("vendor/cache/foo-1.0")).to exist - FileUtils.rm_rf lib_path("foo-1.0") + bundle :cache - run "require 'foo'" - expect(out).to eq("CACHE") + build_lib "foo" do |s| + s.write "lib/foo.rb", "puts :CACHE" end - it "removes stale entries cache" do - build_lib "foo" + bundle :cache - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G + expect(bundled_app("vendor/cache/foo-1.0")).to exist - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - - install_gemfile <<-G - gem "bar", :path => '#{lib_path("bar-1.0")}' - G - - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - expect(bundled_app("vendor/cache/bar-1.0")).not_to exist - end + run "require 'foo'" + expect(out).to eq("CACHE") + end - it "raises a warning without --all", :bundler => "< 2" do - build_lib "foo" + it "removes stale entries cache" do + build_lib "foo" - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{lib_path("foo-1.0")}' + G - bundle cmd - expect(out).to match(/please pass the \-\-all flag/) - expect(bundled_app("vendor/cache/foo-1.0")).not_to exist - end + bundle :cache - it "stores the given flag" do - build_lib "foo" + expect(bundled_app("vendor/cache/foo-1.0")).to exist - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G + build_lib "bar" - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - build_lib "bar" + install_gemfile <<-G + source "https://gem.repo1" + gem "bar", :path => '#{lib_path("bar-1.0")}' + G - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - gem "bar", :path => '#{lib_path("bar-1.0")}' - G + bundle :cache + expect(bundled_app("vendor/cache/foo-1.0")).not_to exist + end - bundle cmd - expect(bundled_app("vendor/cache/bar-1.0")).to exist - end + it "does not cache path gems if cache_all is set to false" do + build_lib "foo" - it "can rewind chosen configuration" do - build_lib "foo" + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{lib_path("foo-1.0")}' + G + bundle_config "cache_all false" - install_gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - G + bundle :cache + expect(err).to be_empty + expect(bundled_app("vendor/cache/foo-1.0")).not_to exist + end - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) - build_lib "baz" + it "caches path gems by default" do + build_lib "foo" - gemfile <<-G - gem "foo", :path => '#{lib_path("foo-1.0")}' - gem "baz", :path => '#{lib_path("baz-1.0")}' - G + install_gemfile <<-G + source "https://gem.repo1" + gem "foo", :path => '#{lib_path("foo-1.0")}' + G - bundle "#{cmd} --no-all" - expect(bundled_app("vendor/cache/baz-1.0")).not_to exist - end + bundle :cache + expect(err).to be_empty + expect(bundled_app("vendor/cache/foo-1.0")).to exist end end |
