Skip to content

Commit abe224c

Browse files
committed
fix: Remove setting local git config
1 parent 379ebc3 commit abe224c

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

spec/spec_helper.rb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
Aruba.configure do |config|
1818
# Increase the default timeout from 3 seconds to 15 seconds.
19-
# This covers standard commands that are just slightly slow.
2019
config.exit_timeout = 15
2120

2221
# Optional: Increase I/O wait time if your tool is slow to output text
@@ -26,30 +25,44 @@
2625
# configure aruba for rspec use
2726
RSpec.configure do |config|
2827
config.include Aruba::Api
29-
# If running in a CI environment, use the verbose 'documentation'
30-
# formatter so we see progress line-by-line.
28+
# If running in a CI environment, use the verbose 'documentation' formatter
3129
config.formatter = :documentation if ENV["CI"]
3230

33-
# We use aruba's helper to prepend the bin path safely for each test.
34-
config.before(:each) do
35-
# 1. Configure Git identity for Unit Tests (running in this Ruby process)
31+
config.around(:each) do |example|
32+
original_env = {
33+
"GIT_AUTHOR_NAME" => ENV.fetch("GIT_AUTHOR_NAME", nil),
34+
"GIT_AUTHOR_EMAIL" => ENV.fetch("GIT_AUTHOR_EMAIL", nil),
35+
"GIT_COMMITTER_NAME" => ENV.fetch("GIT_COMMITTER_NAME", nil),
36+
"GIT_COMMITTER_EMAIL" => ENV.fetch("GIT_COMMITTER_EMAIL", nil)
37+
}
38+
3639
ENV["GIT_AUTHOR_NAME"] = "Tetra Test"
3740
ENV["GIT_AUTHOR_EMAIL"] = "test@example.com"
3841
ENV["GIT_COMMITTER_NAME"] = "Tetra Test"
3942
ENV["GIT_COMMITTER_EMAIL"] = "test@example.com"
4043

41-
# 2. Configure Git identity for aruba and CI tests (running in subprocesses)
44+
# Configure Aruba (for subprocesses)
4245
if respond_to?(:set_environment_variable)
4346
set_environment_variable("GIT_AUTHOR_NAME", "Tetra Test")
4447
set_environment_variable("GIT_AUTHOR_EMAIL", "test@example.com")
4548
set_environment_variable("GIT_COMMITTER_NAME", "Tetra Test")
4649
set_environment_variable("GIT_COMMITTER_EMAIL", "test@example.com")
4750
end
4851

49-
# 3. Existing PATH setup
50-
bin_path = File.expand_path(File.join(__dir__, "..", "bin"))
51-
prepend_environment_variable("PATH", bin_path + File::PATH_SEPARATOR) if respond_to?(:prepend_environment_variable)
52+
example.run
53+
ensure
54+
# Restore the original environment state
55+
original_env.each do |key, value|
56+
if value.nil?
57+
ENV.delete(key)
58+
else
59+
ENV[key] = value
60+
end
61+
end
62+
end
5263

64+
config.before(:each) do
65+
# Add bin path to environment
5366
bin_path = File.expand_path(File.join(__dir__, "..", "bin"))
5467
prepend_environment_variable("PATH", bin_path + File::PATH_SEPARATOR)
5568
end
@@ -61,11 +74,12 @@ module Mockers
6174
# creates a minimal tetra project
6275
def create_mock_project
6376
@project_path = File.join("spec", "data", "test-project")
77+
6478
Tetra::Project.init(@project_path, false)
79+
6580
@project = Tetra::Project.new(@project_path)
6681
end
6782

68-
# deletes the mock project and all contents
6983
def delete_mock_project
7084
FileUtils.rm_rf(@project_path)
7185
end

0 commit comments

Comments
 (0)