summaryrefslogtreecommitdiff
path: root/spec/cache/git_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/cache/git_spec.rb')
-rw-r--r--spec/cache/git_spec.rb342
1 files changed, 170 insertions, 172 deletions
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index 1cb278e912..75525d405b 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -12,230 +12,228 @@ RSpec.describe "git base name" do
end
end
-%w[cache package].each do |cmd|
- RSpec.describe "bundle #{cmd} with git" do
- it "copies repository to vendor cache and uses it" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle cmd
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
-
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "copies repository to vendor cache and uses it even when installed with bundle --path" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
+RSpec.describe "bundle cache with git" do
+ it "copies repository to vendor cache and uses it" do
+ git = build_git "foo"
+ ref = git.ref_for("master", 11)
+
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle "config set cache_all true"
+ bundle :cache
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
+
+ FileUtils.rm_rf lib_path("foo-1.0")
+ expect(the_bundle).to include_gems "foo 1.0"
+ end
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ it "copies repository to vendor cache and uses it even when installed with bundle --path" do
+ git = build_git "foo"
+ ref = git.ref_for("master", 11)
- bundle "install --path vendor/bundle"
- bundle "config set cache_all true"
- bundle cmd
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
+ bundle "install --path vendor/bundle"
+ bundle "config set cache_all true"
+ bundle :cache
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
- it "runs twice without exploding" do
- build_git "foo"
+ FileUtils.rm_rf lib_path("foo-1.0")
+ expect(the_bundle).to include_gems "foo 1.0"
+ end
- install_gemfile! <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ it "runs twice without exploding" do
+ build_git "foo"
- bundle "config set cache_all true"
- bundle! cmd
- bundle! cmd
+ install_gemfile! <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- expect(out).to include "Updating files in vendor/cache"
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
+ bundle "config set cache_all true"
+ bundle! :cache
+ bundle! :cache
- it "tracks updates" do
- git = build_git "foo"
- old_ref = git.ref_for("master", 11)
+ expect(out).to include "Updating files in vendor/cache"
+ FileUtils.rm_rf lib_path("foo-1.0")
+ expect(the_bundle).to include_gems "foo 1.0"
+ end
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ it "tracks updates" do
+ git = build_git "foo"
+ old_ref = git.ref_for("master", 11)
- bundle "config set cache_all true"
- bundle cmd
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :CACHE"
- end
+ bundle "config set cache_all true"
+ bundle :cache
- ref = git.ref_for("master", 11)
- expect(ref).not_to eq(old_ref)
+ update_git "foo" do |s|
+ s.write "lib/foo.rb", "puts :CACHE"
+ end
- bundle! "update", :all => true
- bundle "config set cache_all true"
- bundle! cmd
+ ref = git.ref_for("master", 11)
+ expect(ref).not_to eq(old_ref)
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
+ bundle! "update", :all => true
+ bundle "config set cache_all true"
+ bundle! :cache
- FileUtils.rm_rf lib_path("foo-1.0")
- run! "require 'foo'"
- expect(out).to eq("CACHE")
- end
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
- it "tracks updates when specifying the gem" do
- git = build_git "foo"
- old_ref = git.ref_for("master", 11)
+ FileUtils.rm_rf lib_path("foo-1.0")
+ run! "require 'foo'"
+ expect(out).to eq("CACHE")
+ end
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ it "tracks updates when specifying the gem" do
+ git = build_git "foo"
+ old_ref = git.ref_for("master", 11)
- bundle "config set cache_all true"
- bundle! cmd
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :CACHE"
- end
+ bundle "config set cache_all true"
+ bundle! :cache
- ref = git.ref_for("master", 11)
- expect(ref).not_to eq(old_ref)
+ update_git "foo" do |s|
+ s.write "lib/foo.rb", "puts :CACHE"
+ end
- bundle "update foo"
+ ref = git.ref_for("master", 11)
+ expect(ref).not_to eq(old_ref)
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
+ bundle "update foo"
- FileUtils.rm_rf lib_path("foo-1.0")
- run "require 'foo'"
- expect(out).to eq("CACHE")
- end
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
- it "uses the local repository to generate the cache" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
+ FileUtils.rm_rf lib_path("foo-1.0")
+ run "require 'foo'"
+ expect(out).to eq("CACHE")
+ end
- gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
- G
+ it "uses the local repository to generate the cache" do
+ git = build_git "foo"
+ ref = git.ref_for("master", 11)
- bundle %(config set local.foo #{lib_path("foo-1.0")})
- bundle "install"
- bundle "config set cache_all true"
- bundle cmd
+ gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
+ G
- expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist
+ bundle %(config set local.foo #{lib_path("foo-1.0")})
+ bundle "install"
+ bundle "config set cache_all true"
+ bundle :cache
- # Updating the local still uses the local.
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :LOCAL"
- end
+ expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist
- run "require 'foo'"
- expect(out).to eq("LOCAL")
+ # Updating the local still uses the local.
+ update_git "foo" do |s|
+ s.write "lib/foo.rb", "puts :LOCAL"
end
- it "copies repository to vendor cache, including submodules" do
- build_git "submodule", "1.0"
+ run "require 'foo'"
+ expect(out).to eq("LOCAL")
+ end
- git = build_git "has_submodule", "1.0" do |s|
- s.add_dependency "submodule"
- end
+ it "copies repository to vendor cache, including submodules" do
+ build_git "submodule", "1.0"
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
+ git = build_git "has_submodule", "1.0" do |s|
+ s.add_dependency "submodule"
+ end
- install_gemfile <<-G
- git "#{lib_path("has_submodule-1.0")}", :submodules => true do
- gem "has_submodule"
- end
- G
+ Dir.chdir(lib_path("has_submodule-1.0")) do
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
+ `git commit -m "submodulator"`
+ end
+
+ install_gemfile <<-G
+ git "#{lib_path("has_submodule-1.0")}", :submodules => true do
+ gem "has_submodule"
+ end
+ G
- ref = git.ref_for("master", 11)
- bundle "config set cache_all true"
- bundle cmd
+ ref = git.ref_for("master", 11)
+ bundle "config set cache_all true"
+ bundle :cache
- expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist
- expect(the_bundle).to include_gems "has_submodule 1.0"
- end
+ expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist
+ expect(the_bundle).to include_gems "has_submodule 1.0"
+ end
- it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do
- build_git "foo"
+ it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do
+ build_git "foo"
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- bundle cmd
+ bundle :cache
- expect(err).to include("Your Gemfile contains path and git dependencies.")
- end
+ expect(err).to include("Your Gemfile contains path and git dependencies.")
+ end
- it "does not display warning message if cache_all is set in bundle config" do
- build_git "foo"
+ it "does not display warning message if cache_all is set in bundle config" do
+ build_git "foo"
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
- bundle "config set cache_all true"
- bundle cmd
- bundle cmd
+ bundle "config set cache_all true"
+ bundle :cache
+ bundle :cache
- expect(err).not_to include("Your Gemfile contains path and git dependencies.")
- end
+ expect(err).not_to include("Your Gemfile contains path and git dependencies.")
+ end
- it "caches pre-evaluated gemspecs" do
- git = build_git "foo"
+ it "caches pre-evaluated gemspecs" do
+ git = build_git "foo"
- # Insert a gemspec method that shells out
- spec_lines = lib_path("foo-1.0/foo.gemspec").read.split("\n")
- spec_lines.insert(-2, "s.description = `echo bob`")
- update_git("foo") {|s| s.write "foo.gemspec", spec_lines.join("\n") }
+ # Insert a gemspec method that shells out
+ spec_lines = lib_path("foo-1.0/foo.gemspec").read.split("\n")
+ spec_lines.insert(-2, "s.description = `echo bob`")
+ update_git("foo") {|s| s.write "foo.gemspec", spec_lines.join("\n") }
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
- bundle "config set cache_all true"
- bundle cmd
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+ bundle "config set cache_all true"
+ bundle :cache
- ref = git.ref_for("master", 11)
- gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read
- expect(gemspec).to_not match("`echo bob`")
- end
+ ref = git.ref_for("master", 11)
+ gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read
+ expect(gemspec).to_not match("`echo bob`")
+ end
- it "can install after #{cmd} with git not installed" do
- build_git "foo"
+ it "can install after bundle cache with git not installed" do
+ build_git "foo"
- gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
- bundle! "config set cache_all true"
- bundle! cmd, "all-platforms" => true, :install => false, :path => "./vendor/cache"
+ gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+ bundle! "config set cache_all true"
+ bundle! :cache, "all-platforms" => true, :install => false, :path => "./vendor/cache"
- simulate_new_machine
- with_path_as "" do
- bundle! "config set deployment true"
- bundle! :install, :local => true
- expect(the_bundle).to include_gem "foo 1.0"
- end
+ simulate_new_machine
+ with_path_as "" do
+ bundle! "config set deployment true"
+ bundle! :install, :local => true
+ expect(the_bundle).to include_gem "foo 1.0"
end
end
end