diff --git a/test/supports/mock_env_helper.rb b/test/supports/mock_env_helper.rb index d4607296a51..9dfba9f3989 100644 --- a/test/supports/mock_env_helper.rb +++ b/test/supports/mock_env_helper.rb @@ -1,13 +1,8 @@ # frozen_string_literal: true module MockEnvHelper - def mock_env(partial_env_hash) - old = ENV.to_hash - ENV.update partial_env_hash - begin - yield - ensure - ENV.replace old - end + def mock_env(hash_for_mock, &block) + env_hash = ENV.to_hash.merge(hash_for_mock) + ENV.stub(:[], ->(key) { env_hash[key] }, &block) end end