1616
1717Aruba . 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
2625# configure aruba for rspec use
2726RSpec . 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 if respond_to? ( :prepend_environment_variable )
5568 prepend_environment_variable ( "PATH" , bin_path + File ::PATH_SEPARATOR )
@@ -66,11 +79,12 @@ module Mockers
6679 # creates a minimal tetra project
6780 def create_mock_project
6881 @project_path = File . join ( "spec" , "data" , "test-project" )
82+
6983 Tetra ::Project . init ( @project_path , false )
84+
7085 @project = Tetra ::Project . new ( @project_path )
7186 end
7287
73- # deletes the mock project and all contents
7488 def delete_mock_project
7589 FileUtils . rm_rf ( @project_path )
7690 end
0 commit comments