From 9f543d547d025332689c1662d9e06d66181ad920 Mon Sep 17 00:00:00 2001 From: Miles Georgi Date: Sun, 21 Jul 2024 16:10:05 -0700 Subject: [PATCH] Add code to inflate test repo and test extraction --- spec/foobara/extract_repo_spec.rb | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/foobara/extract_repo_spec.rb b/spec/foobara/extract_repo_spec.rb index 343e442..6e5b420 100644 --- a/spec/foobara/extract_repo_spec.rb +++ b/spec/foobara/extract_repo_spec.rb @@ -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