diff --git a/spec/lib/gitlab/build/check_spec.rb b/spec/lib/gitlab/build/check_spec.rb
index 33ce6868e6e8adb206e2afdabab5676228acb118_c3BlYy9saWIvZ2l0bGFiL2J1aWxkL2NoZWNrX3NwZWMucmI=..e54b486a427430800c8dae7996e51dd0a9f86c97_c3BlYy9saWIvZ2l0bGFiL2J1aWxkL2NoZWNrX3NwZWMucmI= 100644
--- a/spec/lib/gitlab/build/check_spec.rb
+++ b/spec/lib/gitlab/build/check_spec.rb
@@ -24,6 +24,7 @@
         end
 
         it 'when env variable is not set' do
+          stub_env_var('ee', nil)
           stub_is_ee_version(false)
           stub_is_auto_deploy(false)
           expect(described_class.is_ee?).to be_falsy
@@ -32,8 +33,9 @@
 
       describe 'GITLAB_VERSION variable' do
         it 'when GITLAB_VERSION ends with -ee' do
+          stub_env_var('ee', nil)
           stub_env_var('GITLAB_VERSION', 'foo-ee')
           expect(described_class.is_ee?).to be_truthy
         end
 
         it 'when GITLAB_VERSION does not end with -ee' do
@@ -35,8 +37,9 @@
           stub_env_var('GITLAB_VERSION', 'foo-ee')
           expect(described_class.is_ee?).to be_truthy
         end
 
         it 'when GITLAB_VERSION does not end with -ee' do
+          stub_env_var('ee', nil)
           stub_env_var('GITLAB_VERSION', 'foo')
           stub_is_auto_deploy(false)
           expect(described_class.is_ee?).to be_falsy
diff --git a/spec/lib/gitlab/build/info/components_spec.rb b/spec/lib/gitlab/build/info/components_spec.rb
index 33ce6868e6e8adb206e2afdabab5676228acb118_c3BlYy9saWIvZ2l0bGFiL2J1aWxkL2luZm8vY29tcG9uZW50c19zcGVjLnJi..e54b486a427430800c8dae7996e51dd0a9f86c97_c3BlYy9saWIvZ2l0bGFiL2J1aWxkL2luZm8vY29tcG9uZW50c19zcGVjLnJi 100644
--- a/spec/lib/gitlab/build/info/components_spec.rb
+++ b/spec/lib/gitlab/build/info/components_spec.rb
@@ -30,7 +30,7 @@
         # On stable branches and tags, generate-facts will not populate version facts
         # So, the content of the VERSION file will be used as-is.
         it 'returns tag with v prefix' do
-          allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
+          allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
           allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
           expect(described_class.ref).to eq('v15.7.0')
         end
@@ -38,8 +38,8 @@
 
       context 'when on feature branches' do
         it 'returns commit SHA without any prefix' do
-          allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
-          allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
+          allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
+          allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
           expect(described_class.ref).to eq('arandomcommit')
         end
       end
@@ -50,7 +50,7 @@
         # On stable branches and tags, generate-facts will not populate version facts
         # So, whatever is on VERSION file, will be used.
         it 'returns tag without v prefix' do
-          allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
+          allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
           allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
           expect(described_class.ref(prepend_version: false)).to eq('15.7.0')
         end
@@ -58,8 +58,8 @@
 
       context 'when on feature branches' do
         it 'returns commit SHA without any prefix' do
-          allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
-          allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
+          allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
+          allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
           expect(described_class.ref(prepend_version: false)).to eq('arandomcommit')
         end
       end