2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
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
|
|
|
|
gem "foo", :path => '#{bundled_app("lib/foo")}'
|
|
|
|
G
|
|
|
|
|
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "copies when the path is outside the bundle " do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).to exist
|
|
|
|
expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "copies when the path is outside the bundle and the paths intersect" do
|
2020-05-08 01:19:04 -04:00
|
|
|
libname = File.basename(bundled_app) + "_gem"
|
|
|
|
libpath = File.join(File.dirname(bundled_app), libname)
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
build_lib libname, :path => libpath
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "#{libname}", :path => '#{libpath}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
|
|
|
expect(bundled_app("vendor/cache/#{libname}")).to exist
|
|
|
|
expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
expect(the_bundle).to include_gems "#{libname} 1.0"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "updates the path on each cache" do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
build_lib "foo" do |s|
|
|
|
|
s.write "lib/foo.rb", "puts :CACHE"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle :cache
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).to exist
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
run "require 'foo'"
|
|
|
|
expect(out).to eq("CACHE")
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "removes stale entries cache" do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-06 12:41:41 -04:00
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).to exist
|
|
|
|
|
|
|
|
build_lib "bar"
|
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "bar", :path => '#{lib_path("bar-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle :cache
|
2020-06-06 12:41:41 -04:00
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
|
2019-11-11 03:57:45 -05:00
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "raises a warning without --all", :bundler => "< 3" do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle :cache
|
|
|
|
expect(err).to match(/please pass the \-\-all flag/)
|
|
|
|
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "stores the given flag" do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
|
|
|
build_lib "bar"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
gem "bar", :path => '#{lib_path("bar-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle :cache
|
|
|
|
expect(bundled_app("vendor/cache/bar-1.0")).to exist
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
it "can rewind chosen configuration" do
|
|
|
|
build_lib "foo"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
bundle "config set cache_all true"
|
|
|
|
bundle :cache
|
|
|
|
build_lib "baz"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-11-11 03:57:45 -05:00
|
|
|
gemfile <<-G
|
|
|
|
gem "foo", :path => '#{lib_path("foo-1.0")}'
|
|
|
|
gem "baz", :path => '#{lib_path("baz-1.0")}'
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "cache --no-all", :raise_on_error => false
|
2019-11-11 03:57:45 -05:00
|
|
|
expect(bundled_app("vendor/cache/baz-1.0")).not_to exist
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|