Skip to content

Commit 83b06e1

Browse files
authored
Merge pull request #675 from atesgoral/test/windows-environment-lookup
test: avoid stubbing ENV in case-insensitive lookup test
2 parents 00a51d9 + 9d4a472 commit 83b06e1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎test/mcp/client/stdio_environment_test.rb‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ def test_explicit_env_can_select_bundle_gemfile
6666

6767
def test_default_environment_preserves_case_insensitive_variable_lookups
6868
# Windows retains mixed-case names in ENV.to_h but accepts uppercase ENV lookups.
69-
ENV.stubs(:to_h).returns("Path" => "server-path")
70-
ENV.stubs(:[]).returns(nil)
71-
ENV.stubs(:[]).with("PATH").returns("server-path")
69+
environment = Hash.new { |hash, key| hash.find { |name, _| name.casecmp?(key) }&.last }
70+
environment["Path"] = "server-path"
71+
Stdio.const_set(:ENV, environment)
7272

7373
assert_equal("server-path", server_environment["PATH"])
74+
ensure
75+
Stdio.send(:remove_const, :ENV)
7476
end
7577

7678
def test_explicit_env_overrides_default_variables

0 commit comments

Comments
 (0)