Skip to content

Commit

Permalink
Add code to inflate test repo and test extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
azimux committed Jul 21, 2024
1 parent b2d95b7 commit 9f543d5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/foobara/extract_repo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
RSpec.describe Foobara::ExtractRepo do
let(:repo_path) do
"#{__dir__}/../fixtures/test_repo"
end
let(:output_dir) do
# TODO: make this an input to ExtractRepo
"#{ENV.fetch("HOME", nil)}/tmp/extract/test_repo"
end

def inflate_test_repo
Dir.chdir(File.dirname(repo_path)) do
unless Dir.exist?("extract_repo")
`tar zxvf test_repo.tar.gz`
unless $?.exitstatus == 0
raise "Failed to inflate test repo"
end
end
end
end

before do
inflate_test_repo
end

context "when extracting a file that was moved" do
let(:paths) { %w[new_name] }

it "can follow the file's history" do
ExtractRepo.run!(repo_path, paths)

Dir.chdir output_dir do
expect(File).to exist("new_name/new_name.txt")
end
end
end

it "has a version number" do
expect(Foobara::ExtractRepo::VERSION).to_not be_nil
end
Expand Down

0 comments on commit 9f543d5

Please sign in to comment.