diff options
Diffstat (limited to 'spec/install/gemfile/git_spec.rb')
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 83 |
1 files changed, 30 insertions, 53 deletions
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 249ed48eab..067de1777d 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -57,22 +57,18 @@ RSpec.describe "bundle install with git sources" do it "does not update the git source implicitly" do update_git "foo" - in_app_root2 do - install_gemfile bundled_app2("Gemfile"), <<-G - git "#{lib_path("foo-1.0")}" do - gem 'foo' - end - G - end + install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2 + git "#{lib_path("foo-1.0")}" do + gem 'foo' + end + G - in_app_root do - run <<-RUBY - require 'foo' - puts "fail" if defined?(FOO_PREV_REF) - RUBY + run <<-RUBY + require 'foo' + puts "fail" if defined?(FOO_PREV_REF) + RUBY - expect(out).to be_empty - end + expect(out).to be_empty end it "sets up git gem executables on the path" do @@ -130,22 +126,18 @@ RSpec.describe "bundle install with git sources" do it "still works after moving the application directory" do bundle "install --path vendor/bundle" - Dir.chdir root FileUtils.mv bundled_app, tmp("bundled_app.bck") - Dir.chdir tmp("bundled_app.bck") - expect(the_bundle).to include_gems "foo 1.0" + expect(the_bundle).to include_gems "foo 1.0", :dir => tmp("bundled_app.bck") end it "can still install after moving the application directory" do bundle "install --path vendor/bundle" - Dir.chdir root FileUtils.mv bundled_app, tmp("bundled_app.bck") update_git "foo", "1.1", :path => lib_path("foo-1.0") - Dir.chdir tmp("bundled_app.bck") gemfile tmp("bundled_app.bck/Gemfile"), <<-G source "#{file_uri_for(gem_repo1)}" git "#{lib_path("foo-1.0")}" do @@ -155,9 +147,9 @@ RSpec.describe "bundle install with git sources" do gem "rack", "1.0" G - bundle "update foo" + bundle "update foo", :dir => tmp("bundled_app.bck") - expect(the_bundle).to include_gems "foo 1.1", "rack 1.0" + expect(the_bundle).to include_gems "foo 1.1", "rack 1.0", :dir => tmp("bundled_app.bck") end end @@ -224,9 +216,7 @@ RSpec.describe "bundle install with git sources" do s.write("lib/foo.rb", "raise 'FAIL'") end - Dir.chdir(lib_path("foo-1.0")) do - `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1` - end + sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0")) # want to ensure we don't fallback to HEAD update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| @@ -260,9 +250,7 @@ RSpec.describe "bundle install with git sources" do s.write("lib/foo.rb", "raise 'FAIL'") end - Dir.chdir(lib_path("foo-1.0")) do - `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1` - end + sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0")) # want to ensure we don't fallback to HEAD update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| @@ -285,9 +273,7 @@ RSpec.describe "bundle install with git sources" do end it "does not download random non-head refs" do - Dir.chdir(lib_path("foo-1.0")) do - sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1') - end + sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0")) bundle! "config set global_gem_cache true" @@ -300,9 +286,7 @@ RSpec.describe "bundle install with git sources" do # ensure we also git fetch after cloning bundle! :update, :all => true - Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do - sys_exec("git ls-remote .") - end + sys_exec("git ls-remote .", :dir => Dir[home(".bundle/cache/git/foo-*")].first) expect(out).not_to include("refs/bundler/1") end @@ -837,9 +821,7 @@ RSpec.describe "bundle install with git sources" do bundle "update", :all => true expect(the_bundle).to include_gems "forced 1.1" - Dir.chdir(lib_path("forced-1.0")) do - `git reset --hard HEAD^` - end + sys_exec("git reset --hard HEAD^", :dir => lib_path("forced-1.0")) bundle "update", :all => true expect(the_bundle).to include_gems "forced 1.0" @@ -850,10 +832,8 @@ RSpec.describe "bundle install with git sources" do build_git "has_submodule", "1.0" do |s| s.add_dependency "submodule" end - 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 + sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0") + sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0") install_gemfile <<-G git "#{lib_path("has_submodule-1.0")}" do @@ -870,10 +850,8 @@ RSpec.describe "bundle install with git sources" do build_git "has_submodule", "1.0" do |s| s.add_dependency "submodule" end - 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 + sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0") + sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0") install_gemfile <<-G git "#{lib_path("has_submodule-1.0")}", :submodules => true do @@ -1172,16 +1150,15 @@ RSpec.describe "bundle install with git sources" do end 2.times do |i| - Dir.chdir(git_reader.path) do - File.open("ext/foo.c", "w") do |file| - file.write <<-C - #include "ruby.h" - VALUE foo() { return INT2FIX(#{i}); } - void Init_foo() { rb_define_global_function("foo", &foo, 0); } - C - end - `git commit -m "commit for iteration #{i}" ext/foo.c` + File.open(git_reader.path.join("ext/foo.c"), "w") do |file| + file.write <<-C + #include "ruby.h" + VALUE foo() { return INT2FIX(#{i}); } + void Init_foo() { rb_define_global_function("foo", &foo, 0); } + C end + sys_exec("git commit -m \"commit for iteration #{i}\" ext/foo.c", :dir => git_reader.path) + git_commit_sha = git_reader.ref_for("HEAD") install_gemfile <<-G |