Skip to content

Commit

Permalink
Allow with_path_based_gem to specify the directory name
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Jan 3, 2024
1 parent f9db319 commit ecbb5b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions spec/bundler_inject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ecbb5b2

Please sign in to comment.