From ecbb5b2503891c5f5b24ace5e080b48e7e16da30 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Tue, 19 Dec 2023 13:26:42 -0500 Subject: [PATCH] Allow with_path_based_gem to specify the directory name --- spec/bundler_inject_spec.rb | 8 ++++---- spec/support/helpers.rb | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/bundler_inject_spec.rb b/spec/bundler_inject_spec.rb index 4679f3e..c510095 100644 --- a/spec/bundler_inject_spec.rb +++ b/spec/bundler_inject_spec.rb @@ -117,8 +117,8 @@ expect(err).to match %r{^\*\* override_gem\("ansi", :git=>"https://github.com/rubyworks/ansi"\) at .+/bundler\.d/local_overrides\.rb:1$} end - it "with a path" do - with_path_based_gem("https://github.com/rubyworks/ansi") do |path| + it "with an absolute path" do + with_path_based_gem("https://github.com/rubyworks/ansi", "the_gem") do |path| write_bundler_d_file <<~F override_gem "ansi", :path => #{path.to_s.inspect} F @@ -129,8 +129,8 @@ end end - it "with a path that includes ~" do - with_path_based_gem("https://github.com/rubyworks/ansi") do |path| + it "with a full path that includes ~" do + with_path_based_gem("https://github.com/rubyworks/ansi", "the_gem") do |path| path = Pathname.new("~/#{path.relative_path_from(Pathname.new("~").expand_path)}") write_bundler_d_file <<~F diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 088c74a..a025cd0 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -93,14 +93,14 @@ def rm_global_bundler_d_dir FileUtils.rm_rf(Helpers.global_bundler_d_dir) end - def with_path_based_gem(source_repo) + def with_path_based_gem(source_repo, dir_name = "the_gem") Dir.mktmpdir do |path| path = Pathname.new(path) Dir.chdir(path) do - out, status = Open3.capture2e("git clone --depth 1 #{source_repo} the_gem") + out, status = Open3.capture2e("git clone --depth 1 #{source_repo} #{dir_name}") raise "An error occured while cloning #{source_repo.inspect}...\n#{out}" unless status.exitstatus == 0 end - path = path.join("the_gem") + path = path.join(dir_name) yield path end